Recommended way to support backward/forward compatibility in iPhone app? - iphone

I'm in the early stages of an iPhone app and I have a question. I did some searching but did not find what I was looking for.
There are features in iPhone OS4 that I would like to take advantage of, but I would like for my app to also run on 3.X.
It looks like I want to develop against the 4.0 SDK and do the following:
Create a "weak link" to any new (4.0) frameworks
Call respondsToSelector: for any
new method in an existing framework
or any method in a new framework
before making that call
Am I close? What's recommended?
Pointers to similar questions welcome.
UPDATE:
Just as a note - if you are trying to check for a new framework, you're best chance is to call respondsToSelector: on a class method against the class object instead of using an instance method.

Yes, that's exactly how you do it!
The only other trick I can think of that you have not already mentioned is that you build against the latest SDK (i.e., 4.0 in this case) and set the target to be the earliest you want to support (3.0 in this case).
You might like to try using the 3.2 SDK to create a universal (iPhone/iPad) app. This is an Apple template that uses this same method to work with two different APIs.

Related

iSpeech iPhone SDK for monotouch?

Is there a way to use the iSpeech SDK for iPhone in my monotouch project? http://www.ispeech.org/developers/iphone
This looks like an ObjectiveC library. The way to use this inside a MonoTouch project is to create .NET bindings for the library.
There's one reference of this already? existing in their forums but I could not google it. You might want to ask them (iSpeech) if they are aware of it before starting your own bindings.

Flash iOS applications

I am currently building an iOS application with flash CS5 and I would need some help with a couple of the features:
Is it possible to add in-app purchases? If yes, how does that work?
Is it possible to add iAd advertising to the app? If so, how? If not, is there any good alternative that works with flash?
How can I save data from within the app so it will be there eaten if the user restarts the app and even the device (like for a headboard and such)?
Any help is highly appreciated!!! :D
If it were a few months ago. Then answer would be an unequivocal no. However, presently, the answer is "perhaps" (or if you are an optimist, "probably"). With the release of Air 3.0, it now supports Native Extensions. These extensions are native code that have a wrapper API around them so that they can be compiled in with and called from an Air application.
In fact, I decided to look around real quick while researching for this answer and found a repo where it looks like somebody has implemented in-app purchases via a ANE. But I haven't tested this extension personally, but it may be a good starting point to see how it is implemented.
The reason you wont find too much information about ANE's yet is because they were only recently supported in the Air 3.0 update that happened last month. They are currently unsupported in Flash CS5 (or 5.5) or Flash Builder 4.5. They are supported in Flash Builder 4.6, which is currently in a closed beta. But you might be able to sneak in still, and it should be released soon.
The biggest "drawback" is that these extensions need to be developed in the native format for the device you are targeting. So that means, if you want to make an iOS extension, then you are writing it in Objective-C and xcode on a mac.
Pretty much the same answer as before. It should be possible with a ANE. But I haven't found any examples of anybody doing it yet.
It is very simple to save data/state to the device. You'll want to look into the SharedObject.getLocal() method if you want to the LSO. Or you can just use low-level File writing. Check out File.applicationStorageDirectory. For sensitive information that should be encrypted into into the EncryptedLocalStore class, which I believe is supported on iOS but not on Android.
All of these should provide a good way for you to persist data between application sessions.
With AIR 3 you can now use native extensions to call into the native platform code to achieve the functionality not provided by AIR Actionscript APIs. To answer your questions.
in app purchase. I have a sample at http://code.google.com/p/in-app-purchase-air-ios
iAd. I have a sample at http://code.google.com/p/iad-air-ios/
As others have already answered use local shared objects.

What is the best strategy for keeping an android and iphone version of the same app

I'm must build the same application for android and iphone.
I tryed rhodes, that is great, but some native ui features are missing...
I would like to know, is there a strategy, sdk, framework, or something for building native applications for android and iphone that somehow reduce the rework?
Or any suggestion of other framework, like rhodes...
Thanks
Phone Gap is the place for you. You should have a look at this http://www.phonegap.com/about
Appcelerator Titanium
http://www.appcelerator.com/products/titanium-mobile-application-development/
Documentation, Documentation, Documentation!
Have a well written PDR and stick to it.
there is another approach which is to use a tool that generates both simultaneously like: phonegap or corona SDK.
Design for some level of resolution independence. Try to code as much as you appropriately can in HTML rather than native controls. And wrap common API calls so you have 1 method to change rather than 100 different calls all over the place.
You could consider using monotouch and monodroid.
You may also want to see Reusing Monotouch code in Monodroid app

Customising a TableView - iPhone

I am trying to customise a TableView in my iPhone application. I have found many tutorials that do this but they are all for version 3.0+. I want to make my application as generic as possible so I can get it to work on as many iPhones/iTouches as possible.
Is it possible to create a customised TableView for 2.2.1 to 3? I've found nothing and am beginning to think that it's not possible.
You can customize the table in 2.2.1 AFAIK. In fact the tutorial you linked to above was written months before iPhone 3.0 was released!
But I have to agree with the comments above, supporting anything below 3.0 is probably not worth it. In particular, pre-3.0 you would initialize a UITableViewCell using initWithFrame, a method now deprecated. So if you decide to support 2.2.1 you risk your app not working on future releases of iPhone OS. With 4.0 around the corner this would not be a wise move.

Using a custom framework

The error I'm getting:
in /Users/robert/Documents/funWithFrameworks/build/Debug-iphonesimulator/funWithFrameworks.framework/funWithFrameworks, can't link with a main executable
Cliff notes:
trying to include framework
doesn't want to link
More detail:
I'm developing for a mobile device... hint, hint using Xcode and I'm trying to make my
own custom framework which I can include from another application. So far, I've done the following:
Create a new project; an iPhone OS window based app.
Go to target info-> under packaging, change the wrapper extension from app to framework
Go to Action->new build phase -> copy headers. Change roles of headers to 'public'
From my application, I add the framework to the frameworks group.
Apple clearly said that you can not use dynamic libraries on their mobiles. And a private framework is just this.
You can, however, use static libraries.
Egil, that's usually considered as one of the implications of section 3.3.2 of the iPhone developer agreement, which (in part) forbids plug-in architectures or other frameworks. The fact that they don't provide an Xcode project template for an iPhone-compatible framework tends to reinforce the idea, though of course it could just be an oversight or something they're discouraging without actually forbidding.
Whether this is the intended meaning of that section is something you'd have to ask Apple about, and possibly consult a lawyer, but this is where the oft-stated "no frameworks" idea comes from.
For those who have framework code they'd like to use in an iPhone app, an alternative approach is to use the framework code to build a static library. That then gets compiled into the application instead of getting dynamically loaded at run time. The fact that it's part of the application executable avoids any potential concerns about this part of the agreement.
Though dynamic libraries are not allowed, you CAN create a framework (using static libraries and lipo).
Check out: http://accu.org/index.php/journals/1594
I haven't tried it for so called mobile device, but I would guess its very similar to the method for a regular Cocoa application. Check out this tutorial:
Embedded Cocoa Frameworks