Questions tagged [foundation]

Foundation is a framework written in Objective-C that implements many useful classes and functions. For the responsive front-end framework Zurb Foundation, please use the tag [zurb-foundation].

Foundation is a framework written in Objective-C that implements many useful classes and functions. Foundation is used by almost any Objective-C application, as it provides memory management and other runtime features, without the need to use the Objective-C runtime API directly.


References

Related Topics

Separate Topics

This topic is often confused with:

941 questions
10
votes
1 answer

Swift 2 : NSData(contentsOfURL:url) returning nil

I have a webpage address which contains a JSON file. I'm trying to access the JSON file as NSDictionary in Swift 2. Every time I call NSData(contentsOfURL:url!) where url is type of NSURL?, it returns nil. I'm using Xcode 7 Beta, and the project…
Minjae Kwak
  • 185
  • 1
  • 2
  • 8
10
votes
2 answers

NSURL - No mutable subclass, so no need to "copy" as a property?

@interface SomeClass : NSObject @property (copy, nonatomic) NSString *usefulString; @property (strong, nonatomic) NSString *dangerousString; @property (copy, nonatomic) NSURL *curiousURLOne; @property (strong, nonatomic) NSURL…
edelaney05
  • 6,822
  • 6
  • 41
  • 65
10
votes
2 answers

"unrecognized selector sent to class" when calling category method from a library

Problem This question may seem a bit long, but I try to give as much information as possible, since I am really staggered by this. I am currently working an a library which should automate XML document parsing. But I am running into a problem now…
9
votes
3 answers

NSSet and NSCountedSet, when is the best time to use them?

These two collection types are rarely used by me as I'm typically using their counter parts, NSArray, NSDictionary and the equivalent mutables. I have a feeling I'm missing out on a collection which can act much faster than the other two in certain…
Coocoo4Cocoa
  • 48,756
  • 50
  • 150
  • 175
9
votes
3 answers

Should I use NSNumber instead of basic C number types?

What is the benefit of using NSNumber from Foundation Framework instead of basic C types (int, float, double)? Using NSNumber: NSNumber *intNumber; NSInteger myInt; intNumber = [NSNumber numberWithInteger: 100]; myInt = [intNumber…
Fábio Perez
  • 23,850
  • 22
  • 76
  • 100
9
votes
1 answer

1st april dates of 80s failed to parse in iOS 10.0

I found that DateFormatter date(from:) method can't parse a couple of specific dates. Method returns nil for the 1st april of 1981-1984 years. Is it a bug of Foundation? What can we do to perform parsing of such dates? Xcode 8.0, iOS SDK 10.0. Here…
supp-f
  • 1,317
  • 1
  • 9
  • 14
9
votes
1 answer

Replacement for enumerateSubstringsInRange in Swift 3

I'm upgrading code from Swift 2 to Swift 3 and ran across this error: wordcount.swift:7:5: error: value of type 'String' has no member 'enumerateSubstringsInRange' line.enumerateSubstringsInRange(range, options: .ByWords) {w,,,_ in In Swift…
Ray Toal
  • 86,166
  • 18
  • 182
  • 232
9
votes
2 answers

Using instancetype as the return type of a copy in Objective-C?

Using instancetype as a return value of init and related methods is the recommended way to proceed, see the latest clang features. However, what is the best practice w.r.t. the return value of copyWithZone: in the NSCopying protocol (see this thread…
user8472
  • 3,268
  • 3
  • 35
  • 62
9
votes
3 answers

NSLock + atomic property vs nonatomic

I'm fairly new to objective C. If I have a class property that will likely be getting modified during asynchronous events like API calls, what is the best way to make sure that changing the property while it is being accessed by another thread will…
jraede
  • 6,846
  • 5
  • 29
  • 32
9
votes
3 answers

Difference Between Object And NSObject

I'm learning Objective-C and as I can see, in some tutorials they use Object(imported from objc/Object.h) and in others i see the use of NSObject(imported from Foundation/NSObject.h), but what are the main differences between they? Regards.
Nathan Campos
  • 28,769
  • 59
  • 194
  • 300
8
votes
2 answers

Folding/Normalizing Ligatures (e.g. Æ to ae) Using (Core)Foundation

I am writing a helper that performs a number of transformations on an input string, in order to create a search-friendly representation of that string. Think of the following scenario: Full text search on German or French texts The entries in your…
danyowdee
  • 4,658
  • 2
  • 20
  • 35
8
votes
1 answer

Why does String.contains behave differently when I import Foundation?

Just started learning Swift, am really confused about the following behaviour. This is what I get when I run String.contains without Foundation: "".contains("") // true "a".contains("") // true "a".contains("a") // true "" == "" // true And this is…
mingwei
  • 93
  • 6
8
votes
2 answers

Exact float value from a NSString

NSString *str = @"37.3336"; float f = [str floatValue]; f is 37.3335991. Aside from rounding this myself, is there a way to get the exact float value from a NSString?
Morrowless
  • 6,856
  • 11
  • 51
  • 81
8
votes
1 answer

Bridging to/from CoreFoundation on Linux

I'm trying to compile some code on Linux that uses both CoreFoundation and Foundation, but Linux doesn't implement bridging in the same way macOS and iOS do. Bridging between Objective-C and Swift works: import Foundation import…
NobodyNada
  • 7,529
  • 6
  • 44
  • 51
8
votes
2 answers

NSMenu items greyed/disabled for not apparent reason

I have the following code that starts up a "tray icon" and adds a NSMenu to it. #import #import @interface TrayIcon : NSObject @property(strong) NSStatusItem *statusItem; - (void)makeTrayIcon; -…
benstpierre
  • 32,833
  • 51
  • 177
  • 288