User Code List
All my code
---Android
------Sending SMS using Intents
------Send email attachment
------read file from sdcard
------get size of screen
------Accelerometer in Android OS 2.x and deprecated API
------Getting Animation Drawables to actually Animate
------hide the status bar and title bar
------Email, send intent
------wifi scanner
---------New Snippet
------scrollable tabhost
------bluring windows when dialog shows up
------Animated activity transition, diagonal slide
------simple way to scale image
------monitor outgoing phone call
------add directory in sdcard
------EditTextPreference only numbers
------MapView, LongPress, GestureDetector, OnTouchListener
------Preference Screen with custom views
------write and read data from file
------background without stretching
------System setting, change and write_settings
------Creating Persistent AlertDialog for on Orientation Change
------print from Android application
------Screen in landscape mode
------add contact photo to your list
------Distance calculation between 2 Geopoint by Haversine formula
---Iphone
------get iphone orientation
------generate pdf from iphone
------new thread autorelease pool
------determine firmware version
------turn page animation
------load resource file to webview
------call javascript in Objective-C code
------call objective-C code from Javascript
------Disable Webview selection flash
------Disable the action popup
------Disable webview zoom effect
---Utilities
------recursive remove .svn directory
New Snippet
 
 
determine firmware version
 

//determin version

NSString *celltext = [[UIFont familyNames] objectAtIndex:

[indexPath row]];

if ([[[UIDevice currentDevice] systemVersion] hasPrefix:@"2."])

[cell setText:celltext];

else if ([[[UIDevice currentDevice] systemVersion] hasPrefix:@"3."])

[[cell textLabel] setText:celltext];

return cell;

// this too generates compile-time warnings about unimplemented selectors.

NSString *celltext = [[UIFont familyNames] objectAtIndex:

[indexPath row]];

if (![cell respondsToSelector:@selector(textLabel)])

[cell setText:celltext];

else

[[cell textLabel] setText:celltext];

return cell;

To avoid those compile-time warnings, you can add 3.x specific interface declarations to

your 2.x source.

@interface UITableViewCell (SDK3)

- (UILabel *) textLabel;

@end

A better approach, however, is to set the Base SDK and Deployment targets for your project.

In Target Info > Build Settings, set Base SDK to the highest version of the OS you

want to target, namely some 3.x version. Set the iPhone OS Deployment Target to the

lowest OS version you intend to build for.

You can also use a variety of other workarounds like pulling the label out indirectly.

This code retrieves the label and sets its text.

UILabel *label = (UILabel *)[cell valueForKey:@"textLabel"];

if (label) [label setText:celltext];

//Check if the class is available

Class MFMCVC = NSClassFromString(@"MFMailComposeViewController");

If (MFMVC) myMFMCViewController = [[MFMCVC alloc] init];

 
Sub-Article List