After adding Core Data to our Objective-C project and adding an Entity, the build started failing with the error:
The “Swift Language Version” (SWIFT_VERSION) build setting error with project in Objective C
It turns out that the default Code Generation language of Core Data is swift, even if the entire project is written in Objective-C.
To resolve the error, click on the added Entity and look at File Inspector. There is a Code Generation section which you'll need to switch to Objective-C. Alternatively you can add the SWIFT_VERSION in your build settings, but I could not find that in our project. (https://stackoverflow.com/questions/52950514/value-for-swift-version-cannot-be-empty)
Solution found on stack overflow: https://stackoverflow.com/questions/47743271/the-swift-language-version-swift-version-build-setting-error-with-project-in
Showing posts with label objective-c. Show all posts
Showing posts with label objective-c. Show all posts
Friday, September 6, 2019
Saturday, May 17, 2014
Using an Object as a NSDictionary key triggers NSCopying warning
Getting the warning: Sending 'SomeClass *__strong' to parameter of incompatible type 'id'
Usually the NSDictionary key is a string, but it can also be an object as long as it conforms to the NSCopying protocol. The class just needs to be able to respond to the copy and copyWithZone methods so it's safe to cast it according to this SO answer:
http://stackoverflow.com/questions/12525324/unable-to-use-class-as-a-key-in-nsdictionary/12525479#12525479
Usually the NSDictionary key is a string, but it can also be an object as long as it conforms to the NSCopying protocol. The class just needs to be able to respond to the copy and copyWithZone methods so it's safe to cast it according to this SO answer:
http://stackoverflow.com/questions/12525324/unable-to-use-class-as-a-key-in-nsdictionary/12525479#12525479
Sunday, December 15, 2013
Singleton in iOS 4+
Use dispatch_once to create singetons as Apple recommends. See the following examples on stack overflow:
http://stackoverflow.com/questions/5720029/create-singleton-using-gcds-dispatch-once-in-objective-c
http://stackoverflow.com/questions/9119042/why-does-apple-recommend-to-use-dispatch-once-for-implementing-the-singleton-pat
http://stackoverflow.com/questions/5720029/create-singleton-using-gcds-dispatch-once-in-objective-c
http://stackoverflow.com/questions/9119042/why-does-apple-recommend-to-use-dispatch-once-for-implementing-the-singleton-pat
Saturday, February 9, 2013
How to Deprecate a Method in Objective-C
To deprecate a method in objective C you can use __attribute__((deprecated)) like so:
- (id)initWithPermissions:(NSArray *)permissions __attribute__((deprecated));
source:
http://stackoverflow.com/questions/3908715/how-do-i-flag-a-method-as-deprecated-in-objective-c-2-0
keywords:
objc deprecate method
Subscribe to:
Posts (Atom)