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

How can I swap keys and values in NSDictionary?

I want to know how to invert a NSDictionary. I've seen some crazy code like NSDictionary *dict = ...; NSDictionary *swapped = [NSDictionary dictionaryWithObjects:dict.allKeys forKeys:dict.allValues]; which is according to documentation not safe at…
hfossli
  • 22,616
  • 10
  • 116
  • 130
8
votes
2 answers

How to tell if the user turned off cellular data for my app?

Although my app is usable without any internet connection, it may exchange data with a web server (in order to show some user statistics). So I advertise the app as "needs no internet connection". Some users subsequently have turned off cellular…
8
votes
2 answers

alloc + init memory usage mechanism

I am just curious to know when an object has made by alloc, and a piece of memory allocated to it, why init don't use that piece of memory and changes the address of object? NSDate *t = nil; NSLog(@"t = %p",t); // t = 0x0 t = [NSDate…
Hadi
  • 151
  • 7
8
votes
3 answers

Compare NSDictionaries containing NSStrings

I have two NSDictionaries containing NSStrings. To compare this two dictionaries I use isEqualToDictionary: method. The documentation on isEqualToDictionary:says "Two dictionaries have equal contents if they each hold the same number of entries and,…
Anastasia
  • 3,024
  • 1
  • 23
  • 34
8
votes
1 answer

Is an XPC interruption handler called when launchd kills the process?

The documentation for the interruptionHandler block of NSXPCConnection states: An interruption handler that is called if the remote process exits or crashes. However, the Daemons and Services Programming Guide states: XPC services are managed by…
indragie
  • 18,002
  • 16
  • 95
  • 164
8
votes
2 answers

What is the difference between "-copy" and "-copyWithZone:"?

I know that copy creates an immutable copy of an object but i just want to know how copywithzone works and what is the basic difference between copy and copywithzone
prakhar
  • 828
  • 7
  • 18
8
votes
3 answers

NSPredicate 'OR' filtering based on an NSArray of keys

Consider the following NSArray: NSArray *dataSet = [[NSArray alloc] initWithObjects: [NSDictionary dictionaryWithObjectsAndKeys:@"abc", @"key1", @"def", @"key2", @"hij", @"key3", nil], [NSDictionary…
So Over It
  • 3,668
  • 3
  • 35
  • 46
8
votes
1 answer

NSPredicate with a string matching beginning of words

This must be a duplicate. But with so many NSPredicate questions out there, I can't find the right one. I have a list of Core Data objects that contain a compositeName field. A name like 'Emily Blunt' could be in there. I want to search the list…
epologee
  • 11,229
  • 11
  • 68
  • 104
8
votes
2 answers

NSPredicate to check if attribute of object exits, if it does, get it

I'm not even sure of this is possible, but if it is, it could surely help. I have an NSArray of NSDictionaries. Each dictionary has certain keys (obviously). Dict{ Title: WBCCount Cat: Lab } Dict{ Title: HbM Cat: Lab Sex: Male } Dict{ Title:…
8
votes
2 answers

Cocoa: Detecting USB devices by Vendor ID

I'm writing a Foundation tool for Mac and trying to detect when Apple devices are connected and disconnected via USB. I found some help in this post along with the USBPrivateDataSample -- but it seems to only be working if I provide both a vendor ID…
skandocious
  • 814
  • 9
  • 21
8
votes
3 answers

Accessing value from array of objects

I am having two arrays, Namely NMutableArray* first; NMutableArray* second; Now I am copying first object to the second array like for (int i=0;i
Perseus
  • 1,546
  • 4
  • 30
  • 55
7
votes
1 answer

Swift 5.5: Asynchronously iterating line-by-line through a file

In the "Platforms State of the Union" video of WWDC2021 at 28:00 it was mentioned that [Apple] even added support for asynchronously iterating line-by-line through a file in Foundation for macOS 12/iOS 15 and Swift 5.5. What is that new API, how…
YourMJK
  • 1,429
  • 1
  • 11
  • 22
7
votes
0 answers

Why does Swift NumberFormatter require a non-breaking space to work properly?

I have a UITextField with a mask formatting my input to the BRL currency, so input 1700 from keyboard results in R$ 1.700,00 text, but since I need this value as double, NumberFormatter was used like this: var currencyFormatter: NumberFormatter { …
Cayoda
  • 189
  • 6
7
votes
2 answers

Swift foundation vs standard library?

Question - What is the difference between Swift Foundation and standard library? I know they are not in the same repository. Swift standard library and Swift Foundation. My understanding is that Swift standard library is low level library that are…
La Win Ko
  • 254
  • 2
  • 10
7
votes
2 answers

How is Key-Value Observing implemented internally?

I got answer about Foundation magic for this question: What's the most *simple* way to implement a plain data object which conforms key-value-observing? What's the magic? How it work internally? Because it's dangerous using framework which I can't…
eonil
  • 83,476
  • 81
  • 317
  • 516