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
33
votes
1 answer

Using isKindOf in Swift

I use Xcode 8.0 beta to test my app, but after it convert my code 2.2 to 3.0, came out many unsolved bugs. Below the demo, Xcode8.0 appear the error message 1. Expected "{" after "if" condition... if annotation.isKindof: (MKUserLocation) { …
Wangdu Lin
  • 913
  • 1
  • 9
  • 19
33
votes
2 answers

CoreFoundation vs Foundation

In iPhone development, speed is of the essence. Does anyone know if there is a speed difference between using a CoreFoundation type (like CFMutableDictionaryRef) versus a Foundation type (its counterpart, NSMutableDictionary). I would think…
grmartin
  • 1,399
  • 2
  • 12
  • 23
32
votes
4 answers

How to use NSIndexSet

In Objective-C, my program opens a window and displays a table. I want to have a specified row of the table highlighted. How do I do this? I seem to need the code [myTableView selectRowIndexes:(NSIndexSet *) byExtendingSelection:(BOOL)]; I looked…
hertopnerd
  • 618
  • 1
  • 5
  • 9
32
votes
5 answers

How to use KVO for UserDefaults in Swift?

I'm rewriting parts of an app, and found this code: fileprivate let defaults = UserDefaults.standard func storeValue(_ value: AnyObject, forKey key:String) { defaults.set(value, forKey: key) defaults.synchronize() …
Sti
  • 8,275
  • 9
  • 62
  • 124
30
votes
1 answer

Does NSSet's containsObject: test for pointer equality or value equality?

Say I have an NSSet with a string in it. If I send containsObject: with another string which is a different pointer but the exact same string value, will that return YES? Also, is it the same story when it comes to removeObject:? I.e., different…
Chris
  • 39,719
  • 45
  • 189
  • 235
30
votes
12 answers

Error message "could not build module 'Foundation'"

I searched for this question and could not find much help. Error: could not build module 'Foundation' #import What is the problem?
Robert Cannistraci
  • 303
  • 1
  • 3
  • 4
30
votes
3 answers

Merging NSArrays in Objective-C

I have an NSDictionary where each key points to an array. I later want to merge all of the values into one array. Is there a way to use the API to do something more efficient than say: NSArray *anArray = [someDictionary allValues]; NSMutableArray…
Coocoo4Cocoa
  • 48,756
  • 50
  • 150
  • 175
23
votes
2 answers

iOS 15 warning: NSKeyedUnarchiver _warnAboutPlistType:missingInAllowedClasses:

Xcode 13 and iOS 15 began warning about missingAllowedClasses when using custom DataTransformers. There is very little documentation on custom DataTransformers, so I thought I would post a question and answer it here. [general] ***…
Tom GODDARD
  • 641
  • 6
  • 9
22
votes
2 answers

Keep NSThread alive and run NSRunLoop on it

So I'm starting a new NSThread that I want to be able to use later by calling performSelector:onThread:.... From how I understand it calling that methods add that call to the runloop on that thread, so on its next iteration it will pop all these…
Erik Rothoff
  • 4,826
  • 9
  • 41
  • 59
22
votes
2 answers

How to resolve 'scanLocation' was deprecated in iOS 13.0

When trying to use a Scanner I am getting the warning that 'scanLocation' was deprecated in iOS 13.0. Since being able to scan from the next location is rather fundamental to scanning a String, wondering what to use instead of scanLocation. Apple's…
Chuck Krutsinger
  • 2,830
  • 4
  • 28
  • 50
21
votes
2 answers

About -(NSDictionary)dictionaryWithObjectsAndKeys: and

I got a really interesting question. Inside one of my classes I declared a very simple instance method -(NSDictionary)dictionary; that is implemented in this way: - (NSDictionary *)dictionary { return [NSDictionary dictionaryWithObjectsAndKeys: …
Gabriele
  • 1,163
  • 1
  • 11
  • 24
21
votes
1 answer

Why does String.subscript(_:) require the types `String.Index` and `Int` to be equal when there is no `Int` involved?

I fail to understand the problem Xcode is confronting me with in this line: iteration.template = template[iterationSubstring.endIndex...substring.startIndex] template is a String and iterationSubstring and substring are Substrings of template.…
p13n
  • 859
  • 8
  • 31
21
votes
1 answer

How to check for API availability in Xcode 9

I'm using he UserNotification framework that is available only in iOS 10. I am declaring a method that uses this framework and so far, I have been doing the check for the availability as follows: @interface MyService : NSObject #if…
Jan
  • 7,444
  • 9
  • 50
  • 74
20
votes
5 answers

What is the logic behind having a mutable and immutable versions of classes like NSArray, NSDictionary etc in Objective C?

Why do common collection classes in Objective C like NSString, NSArray, NSDictionary etc have a mutable as well as an immutable version. What is the logic behind defining them separately? Performance, memory management or anything else?
NSExplorer
  • 11,849
  • 12
  • 49
  • 62
20
votes
2 answers

What is the data structure behind NSMutableArray?

Usually, a "mutable array" class is implemented as a wrapper around a simple array. The wrapper allocates more memory when you add an element past the end. This is a common data structure and the performance of the various operations is well known.…
Rob N
  • 15,024
  • 17
  • 92
  • 165
1
2
3
62 63