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
14
votes
3 answers

KVO on Swift's computed properties

Is KVO on a computed property possible in Swift? var width = 0 var height = 0 private var area : Double { get { return with * height } } self.addOberser(self, forKeyPath: "area", ...... Would a client code modifying the with or…
David Homes
  • 2,725
  • 8
  • 33
  • 53
14
votes
2 answers

NSLocaleCountryCode returns nil

I have a bugreport that states a crash in the following line, where client is an instance of NSMutableDictionary [client setObject:[[NSLocale currentLocale] objectForKey:NSLocaleCountryCode] forKey:@"country"]; My guess is, that NSLocaleCountryCode…
Michael Ochs
  • 2,846
  • 3
  • 27
  • 33
13
votes
6 answers

Adding non NSObjects to NSMutableArray

This recent SO discussion has confused me. The NSMutableArray prototype for addObject: is - (void)addObject:(id)anObject and id is defined in objc.h as typedef struct objc_class *Class; typedef struct objc_object { Class isa; } *id; When I…
jbat100
  • 16,757
  • 4
  • 45
  • 70
12
votes
1 answer

Get decimal separator of decimal pad keyboard on iOS

I am trying to find out which decimal separator is used by the decimal pad keyboard in iOS, so I can convert strings entered by the user to numbers with NumberFormatter and back. As I want to pre-fill the text field with an existing value, I need to…
Palle
  • 11,511
  • 2
  • 40
  • 61
12
votes
4 answers

Writing Data to an NSOutputStream in Swift 3

The solution of this question no longer works with Swift 3. There is no longer a property bytes of Data (formerly NSData. let data = dataToWrite.first! self.outputStream.write(&data, maxLength: data.count) With this code, I get the error: Cannot…
ahyattdev
  • 529
  • 1
  • 6
  • 18
12
votes
2 answers

What's the difference between NSLocale currentLocale vs autoupdatingCurrentLocale?

What's the difference between NSLocale currentLocale vs autoupdatingCurrentLocale? It's not obvious from reading the documentation.
Boon
  • 40,656
  • 60
  • 209
  • 315
12
votes
4 answers

NSDictionary +dictionaryWithDictionary or -copy?

Which is considered the better way to derive a new dictionary from an original one: [NSDictionary dictionaryWithDictionary:otherDictionary]; or [otherDictionary copy]; ? From time to time we need to make a mutable dictionary out of an immutable…
matehat
  • 5,214
  • 2
  • 29
  • 40
11
votes
5 answers

How to list all folders and their subdirectories/files in iPhone SDK?

I want the user to select any file present in her/his iPhone so that it’s used as an e-mail attachment. For this purpose, I want to show the list of all files and folders present in iPhone. But how would I get the list of those files? Is there any…
Muhammad Saqib
  • 993
  • 2
  • 15
  • 37
11
votes
1 answer

Catching NSJSONSerialization errors in Swift

I'm trying to understand why I'm unable to catch the errors thrown by NSJSONSerialization. I expect the NSInvalidArgumentException exception to be raised and caught, but instead the app crashes. This is occurring in both Swift 3 and Swift 2.3 using…
Erik Villegas
  • 954
  • 13
  • 29
11
votes
2 answers

Positive NSDecimalNumber returns unexpected 64-bit integer values

I've stumbled onto an odd NSDecimalNumber behavior: for some values, invocations of integerValue, longValue, longLongValue, etc., return the an unexpected value. Example: let v = NSDecimalNumber(string: "9.821426272392280061") v //…
Cora Middleton
  • 956
  • 7
  • 13
11
votes
2 answers

How to pass pan gesture to UICollectionVIew from UICollectionViewCell?

I have a UICollectionView implementing a grid-based layout of custom UICollectionViewCells. To allow cells to respond to dragging, I individually add a UIPanGestureRecognizer to each cell. The UICollectionView still scrolls (horizontally) when I…
Erika Electra
  • 1,854
  • 3
  • 20
  • 31
11
votes
1 answer

What is the correct way to self-terminate a MacOS XPC service?

I've successfully followed the Daemons and Service Guide - Creating XPC Services tutorial, along with the SandboxedFetch sample code and have a working Client / Service setup that is using the new NSXPCConnection class. What still isn't entirely…
kennyc
  • 5,490
  • 5
  • 34
  • 57
11
votes
2 answers

How can I do things like Clojure when using immutable collections in Objective-C?

I've become somewhat addicted to using immutable collections (mainly in Clojure, which calls them "persistent data structures"), and would love to be able program this way in some contexts on iOS and OS X. A key example of where this would be useful…
Matthew Phillips
  • 1,275
  • 1
  • 12
  • 19
11
votes
6 answers

How do I create dummy JSON data on the client in objective C / iOS?

I want to set up static dummy data, in JSON, for my app to process. This is purely client-side; I don't want to retrieve anything from the network. All the questions and answers I've seen so far have NSData* variables storing what's retrieved from…
Danny
  • 3,670
  • 12
  • 36
  • 45
11
votes
3 answers

What is the purpose of the -self method in NSObject-conformant classes?

That's it. Why would anyone want (at least as a public API) a method such as that? Is there any practical use for it?
Matoe
  • 2,742
  • 6
  • 33
  • 52