Including iOS 6 properties in an object for an iOS 4.3 backwards-compatible app? - objective-c

I'm adding some iOS 6 features to an existing app -- specifically, the built-in facebook integration. However, I need my app to retain backwards compatibility with iOS 4.3.
In most code, I understand how to handle this using respondsToSelector; I also understand to weakly link the Social and Accounts frameworks so they're only loaded if available.
What I don't know, though, is this: In order to enable the Facebook integration, I need to add a property to my "ShareViewController" -- which handles all the sharing for my app -- to hold the composition sheet, i.e.:
SLComposeViewController *mySLComposerSheet;
However, SLComposeViewController is a class that exists only in iOS6. So essentially, I need that property only to exist if the user is running iOS 6.
How does one handle this sort of situation?

It will just work. There's some metadata in the property/ivar that references the class name, but it doesn't actually link against the class or cause an error at runtime.
Of course, always test!

I suggest you use NSClassFromString and [UIDevice isSystemVersionHigherOrEqualTo:#"6.0"].

Related

How can I determine if my Cocoa Desktop application is on the list of apps to be opened at login?

I am developing a SandBoxed Cocoa Application. I have successfully implemented the Launch at login feature by using the Core Foundation function:
SMLoginItemSetEnabled
I have based the implementation on This tutorial
But now I need a way to determine if my app is set to be launched at login, so that I can show the button in the appropriate position upon launch. I would expect a similar Core Foundation function to find out if a bundle identifier is on the list of login items, but I didn't find it.
Another problem is that, by using this Core Foundation approach, although it is recommended by Apple, my app is still inconsistent with the "Open at Login" tick in my application dock menu.
You can do it using the functions in the LSSharedFileList.h header, which is in LaunchServices.framework, which is in CoreServices.framework. As far as I can tell, Apple hasn't documented this stuff except in the header comments, but that's probably enough. The basic outline is that you first create a LSSharedFileListRef using the function LSSharedFileListCreate for the list type kLSSharedFileListSessionLoginItems. Then copy a snapshot of the list (which is a CFArrayRef) using LSSharedFileListCopySnapshot. Then for any item in the array, you can get its URL using LSSharedFileListItemCopyResolvedURL. That last function requires Mac OS X 10.10 or later, while I think the others date back to 10.5.
By the way, the docs on SMLoginItemSetEnabled say that it's for setting an embedded helper app as a login item, but it sounds like you're talking about a freestanding app.
Apple's sandbox documentation says:
With App Sandbox, you cannot create a login item using functions in the LSSharedFileList.h header file. For example, you cannot use the function LSSharedFileListInsertItemURL.
But maybe you can still use the shared file list functions on a read-only basis.

How to know about app launched and details jailbreak iOS 7

I am making a tweak for iOS 7, in which I want to know about app launch event, and the details of app being launched (name and identifier). So far the only useful framework I have found is SpringBoardServices.framework. The header files which may be/are useful to track app launch event include:
SBAppLaunchUtilities.h
SBLaunchAppListener.h
If I am on right track, can anyone provide me information about their methods usage? There is no relevant information or guide present on iphonedevwiki.
Moreover, How can I get information about app launched? I have studied Andy ibanez's tutorial. It hooks SBApplicationIcon class, which I guess has been removed from iOS 7 frameworks because I can't find it in dumped frameworks. So what is alternate header? Is it SBSCardItem.h and SBSCardItemsController ?
Looking forward for help. Thanks.
You need to look into SpringBoard.app instead of SpringBoardServices.framework. SpringBoard app comes "alone" because like it's extension implies, it's an app, and not a framework that can be found in the entire Private Frameworks.
You can get a lot of info from the SBApplicationIcon class in SpringBoard, such as the app display name and things like that. Check the headers for more info.

Properties of iOS messenger

I need to build an app such as "Messages" in iPhone, but easier (don't need to send messages to server, only in datebase). I was faced with some questions.
http://www.ibm.com/developerworks/library/x-ioschat/index.html
In this tutorial messages look like TableView, how can I do them such as in iPhone standard messanger (comics speach). And how can I implement bar with camera button, text box and send button (what class is responsible for this)?
You are in luck good sir, there is already a class that can fix you up with this and avoid all the work, it's called AcaniChat (screenshot provided). Or you can even see at Sam Soffle's SSMessagesViewController, he is a well known iOS developer who built this class.
It will definitely help you, if you want to mimic that behavior.

How do i migrate an app to iOS 5? (or turn on ARC)

I've got an app i'm working on and i just started using iOS 5. I'd like to start using Automatic Reference Counting but I'm not sure what steps i need to take to either migrate to iOS 5 or at least to turn on ARC.
If you look in Edit > Refactor menu, you'll see an option called Migrate to Objective-C ARC. That tool will help convert your code to ARC.
iOS 5 docs are not publically viewable yet, but in your Xcode you can go to the Organizer and view documentation. Search for "Programming with ARC Release Notes" and there's a document in there which will hopefully answer most of the questions you have about the process.

How build a custom control in Xcode for the iPhone SDK?

I want to build a custom control to reuse in my project which consists of two UITextFields that are linked together + a label.
It is starting to become repetitive across my App and smells of code duplication ;)
However, I wonder what is the best aproach here.
Is it best do everything by code in a controller or is posible do a visual thing like the ones built-in in Xcode?
You can build an Interface Builder plug-in for this. It's fairly straight-forward. To get started, read the Interface Builder Plug-In Programming Guide. It even has a quick, step-by-step tutorial to get you started. Apple recommends creating a plug-in to IB for just your case...
I don't think this is possible. I briefly looked at the IB Plug-In Programming Guide and apparently Interface builder plugins are implemented through Custom Cocoa Frameworks. That is, your plugin is defined in a framework which is loaded in Interface Builder. IB looks in the current projects frameworks to find any custom components defined and will load plugins accordingly. It is not possible to use custom or third party frameworks on the iPhone so I don't see how IB would make a connection here. If somebody has more info I'd love to see this discussion continued.
This is fine except it is for the iPhone. The iPhone presents a more difficult environment to create the plug-in for interface builder. It should be possible but I have yet to see a Xcode project that does this. They are all limited to creation of desktop "AppKit" versions, not iPhone "UIKit" versions of the plugins for IB.