Is the literal object syntax only available for OS X development? - objective-c

Are the new Objective-C literal syntax additions (e.g. #3.14) only available when developing for OS X and not iOS? That's what the Xcode update 4.4 seems to suggest. If so, why?

No, they’re also available in the 4.5 preview and work on iOS.

Related

Multipeer Connectivity between iOS and OS X

I'm trying to make an application that can share data between OS X and iOS using the multipeer connectivity framework. From what I understand I need two applications, one for OS X and one for iOS if I want them to communicate data both ways. Would they both have to be made with obj-c or can I make the iOS app using swift and the OS X with obj-c?
You can use either language on either platform. The multipeer framework can be called from Swift or Objective C and any combination will work.
In fact, it is possible to use the exact same code on both platforms by setting up a workspace with targets for iOS and OSX and common code included in both.

objectForKeyedSubscript: crash on iOS 5.1

I'm running some code that does a [NSDictionary objectForKeyedSubscript:] and it's crashing on iOS 5, but not iOS 6. I am using xcode 4.5.2 and compiling against the iOS 6.0 SDK.
I assumed that this would work on iOS 5 since it's just a compiler feature? Am I wrong about that? I can just write my own versions of those functions, but I'm worried that something else is wrong since I would expect it to work.
NSDictionary reference for IOS in Apple developer
Available in iOS 6.0 and later.
OK, I'm going to answer my own questions, although I don't completely understand why it was failing.
Using objectForKeyedSubscript: and the like works fine running in iOS 5 (as long as it was compiled against the iOS 6 SDK).
The problem was I named a function +(void)load and making objectForKeyedSubscript: calls in this function causes an assert due to the method not being found.
This was an naming error on my part because the load method is called before the App is fully running. I have changed the name of my function and all is well.
I assume +load is being called before something with NSDictionary is fully inited. Odd that it works under iOS 6 and just not iOS 5.
Maybe that's not odd.
There is a workaround for pre-iOS6 SDKs
Checkout question here: Is there any way to get the neat Objective-C literal indexing feature in Xcode 4.4?

Convert GameCenterManager to ARC

Im using the GameCenterManger from Apple's GKTapper demo. I decided I want to convert my project to arc, but I keep getting an error saying "GameCenterManager.h:67:43: The current deployment target does not support automated __weak references". Any help would be appreciated, thanks!
https://developer.apple.com/library/ios/#samplecode/GKTapper/Introduction/Intro.html
"Weak" not support iOS 4.0 target.
1st way...
if your project is newer. change target to iOS 5.0 or later.
2nd way...
You should support iOS 4.0.
You can use assign keyword.
But assign do not support setting to nil.

Why does ARC work for iOS 4.0+ only?

What is the technical reason for ARC to be supported by iOS 4.0 and above only?
It is my understanding that it is a compiler feature, which merely inserts memory management related code automatically instead of requiring the developer to do so. From what I read the calls themselves remain the same - at least that's what Apples Transitioning to ARC Guide implies.
As such, it should not involve features that have not been present in previous versions of iOS, and indeed ARC does work with iOS 4.0 despite having been introduced later.
I'm asking this question out of curiosity and don't actually need to make ARC work with iOS 3.x.
It is for the same reason that automatic reference counting only supports 64-bit Snow Leopard as a minimum deployment target: ARC support requires certain features present only in a new enough version of the modern runtime. That modern runtime was introduced with iOS 4.0, so older iOS versions lack the runtime capable of handling some of the things required technically by ARC. If it were just keyed to OS versions, 32-bit Snow Leopard applications would be supported as well, but only the 64-bit runtime is the modern one there.
If you watch Apple's presentations from WWDC 2011, particularly the "Objective-C Advancements In-Depth," you'll see that a number of under-the-hood improvements have been made to speed up the retain / release process, as well as things like the faster #autoreleasepool. There's an entire section on runtime support in the LLVM ARC specification. These improvements require more than just compiler support.
We already had to use the modern runtime for features like automatic synthesis of instance variables (as explained in Apple's documentation), so this isn't a terrible surprise.
Even iOS 4.0 as a target lacks support for weak references, so there are clearly technical issues at play here. This isn't just a marketing strategy to drive developers to the newer versions, as has been asserted by others.
The docs of Apple states that the dealloc chaining to super is handled in runtime in the case of ARC.
The kind of a same question would be:
Why is NSRegularExpression only supported by iOS 4.0+ and Mac OS X 10.7(Lion)+?
You have fully working simulators of iOS 5.0(and 4.0 obviously) in Mac OS X 10.6.7(Snow Leopard) where you can easily use NSRegularExpression, but it's not supported by Mac OS X 10.6.7 itself.
And concerning your question: ARC was introduced with iOS 5.0. At that time there were not many iOS 3.x users anymore, so my opinion is that Apple was a bit too lazy to make ARC compatible with iOS 3.x.
My guess would be that the clang tool chain (required for ARC) does not build binaries compatible with iOS 3.x.
Also, there are a couple of C functions used in place of sending -retain and -release that might not be available in iOS 3.x
http://www.informit.com/articles/article.aspx?p=1745876

How check the availably of all objective-c function in source code for Cocoa

When you read the Class Reference of every object of iOS, you will find:
Available in iOS 2.0 and later.
There are a program or a way to list all function and the minimum iOS system?
How can I know if the iPhone with iOS 3.0 will run all iOS function? I can check it in runtime with respondToSelector, but can be more easy with source code?
Set your project's base SDK to iOS 3, and see if it builds.
AFAIK there is no way to list all the APIs you use in your app into one list and check that you are building past the minimum for all those APIs. You will just have to check each one, one by one. Highlight the API in Xcode, and then click escape and it will tell you very easily.
But also I have to mention that this won't be extremely necessary since you should test on the minimum OS you are building for and if it crashes at any point then you have your issue for that certain API.