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
19
votes
2 answers

NSUserDefaults boolforKey limitation by design?

The NSUserDefaults API documentation has the boolForKey: message which is described like this - boolForKey: Returns the Boolean value associated with the specified key. - (BOOL)boolForKey:(NSString *)defaultName Return Value If a boolean value is…
NP Compete
  • 2,369
  • 2
  • 16
  • 15
18
votes
2 answers

NSJSONSerialization generating NSCFString* and NSTaggedPointerString*

Executing NSJSONSerialization on the following json sometimes gives me NSCFString* and sometimes NSTaggedPointerString* on string values. Does anyone know why this is the case and what NSJSONSerialization uses to determine which type it…
18
votes
6 answers

[__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance

I am trying to add "dateTime" to My dictionary as defined follows: Symptom Ranking: { 5111ef19253b4a9150000000 = 1; 5111f029253b4add4e000000 = 1; 5111f036253b4a123d000001 = 1; 5111f045253b4a404f000000 = 1; } NSLog(@"date selected:…
Strong Like Bull
  • 11,155
  • 36
  • 98
  • 169
17
votes
3 answers

Why do Objective-C objects have to be dynamically allocated?

Why do Objective-c objects have to be dynamically allocated? Why do I have to make it a pointer to an object, unlike in C++ I can create them on stack? Thanks.
17
votes
9 answers

Why are NSRect, NSPoint, etc. structs, not classes?

I've recently needed to create my own type similar to NSRect that has an anchor point (essentially an NSRect with another NSPoint in it). After some research I found that I was actually probably better off to just make this a class (as in NSObject…
Oliver Cooper
  • 849
  • 7
  • 20
17
votes
2 answers

CoreFoundation Trap error "Thread1:EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xdefe)"

i need your help i've got this frustrating "random" error. The app is compose of one Mapviewcontroller and a collectionview on the second controller. Sometimes when I return to the map from the second controller the app suddenly crash with this…
Dodgson86
  • 333
  • 1
  • 4
  • 15
16
votes
2 answers

Is NSIndexPath threadsafe?

Apple's multithreading docs don't list NSIndexPath as threadsafe or not! As an immutable class, I'd generally expect it to be threadsafe. Previously, I'm sure the documentation used to state that NSIndexPath instances were shared and globally…
Mike Abdullah
  • 14,933
  • 2
  • 50
  • 75
16
votes
1 answer

Swift: String starts(with:) vs hasPrefix

String.hasPrefix (or [NSString hasPrefix]) was always part of Foundation. However, I just noticed that now we also have starts(with:). This method comes from Sequence but it also works for String. My question is, which one should I prefer? Are there…
noamtm
  • 12,435
  • 15
  • 71
  • 107
16
votes
1 answer

Can DateComponentsFormatter format fractional seconds?

I want to print, e.g., the value 1.5 as "1.5 sec", like Safari's timeline does, and I'm trying to use DateComponentsFormatter for it. Unfortunately, its .allowedUnits only goes down to .second (even though the enum has .nanosecond). I tried setting…
16
votes
1 answer

What does startAccessingSecurityScopedResource() actually do?

I'm making a sandboxed Mac app, and I used NSOpenPanel to get a file URL, and saved it to UserDefaults as a security-scoped bookmark. When I quit and restart the app, I can resolve that blob of Data into a URL again. The documentation says I should…
Ssswift
  • 916
  • 10
  • 20
15
votes
1 answer

CFRunLoopRun() vs [NSRunLoop run]

I have an NSRunLoop object, to which I attach timers and streams. It works great. Stopping it is another story alltogether. I run the loop using [runLoop run]. If I try to stop the loop using CRunLoopStop([[NSRunLoop currentRunLoop] getCFRunLoop]),…
Jörgen Sigvardsson
  • 4,839
  • 3
  • 28
  • 51
15
votes
4 answers

How to delete the contents of the Documents directory (and not the Documents directory itself)?

I want to delete all the files and directories contained in the Documents directory. I believe using [fileManager removeItemAtPath:documentsDirectoryPath error:nil] method would remove the documents directory as well. Is there any method that…
NSExplorer
  • 11,849
  • 12
  • 49
  • 62
15
votes
2 answers

What is a KeyPath used for?

In Swift 4 many on the Foundation team have discussed how much easier it is to use keyPaths as compared to Swift 3. This begs the question... What is a keyPath? Seriously, I can't find any clear resources.
Brandon Bradley
  • 3,160
  • 4
  • 22
  • 39
15
votes
3 answers

Swift Playground - Files are not readable

Files are not readable in Swift Playground. How to make files readable? Same code runs well on Xcode terminal app, but fails on Swift Playground. Demo code below. import Foundation println("Hello, World!") var fname:String =…
D.A.H
  • 858
  • 2
  • 9
  • 19
14
votes
1 answer

Difference between containsObject: and member: methods of NSSet?

What is the diference between these two methods belonging to the NSSet class: -(BOOL)containsObject:(id)anObject -(id)member:(id)object
NSExplorer
  • 11,849
  • 12
  • 49
  • 62
1 2
3
62 63