CategoryiOS

How to pick music file from music library in iPhone application

H

Like UIImagePickerView to pick image from image gallery we can also pick up any music file from the music gallery of the device and can use it in our application with the help of MPMediaPickerController. For that you need to add AVFoundation framework in your application. also to play the picked file we need to add MediaPlayer framework. and to use them just import them in respective view...

Function For returning Multiple values in iphone

F

Function For returning Multiple values in iphone – (void)viewDidLoad { [super viewDidLoad]; //Return In Dictionary NSDictionary *FullName = [Self FullnameDict:@”AAAA,BBBB”]; NSString *FName = [Name objectForKey:@”firstame”]; NSString *LName = [Name objectForKey:@”lastname”]; //Return In Array NSArray *FullName1 = [Self...

Conversion of NSString to NSDate and NSDate to NSString

C

  Here is the way to convert NSDate to NSString in objective C Conversion of NSDate to NSString : NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@”yyyy-dd-MMM”]; NSString *dateString = [dateFormat stringFromDate:today]; NSLog(@”date: %@”, dateString); [dateFormat release]; Note that today should be your NSDate object which you...

Extracting data from Apple iTunes

E

I tried a lot to find RSS feeds for latest apps getting posted on Apple iTunes store under all categories but couldnt find anywhere, not sure why Apple does not provide such feed. So I decided to write one of my own and below is how I accomplished the task using curl in php. Through httpfiddler I first out request headers sent by iTunes software and used the same.   <?php function...

How to get sprite animation frames using spritesheet in cocos2d

H

if you are using SpriteSheet for animation,you can extract all required frame like this…     [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"spritesheet.plist"];     CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"spritesheet.png"];     [self addChild:spriteSheet];      NSMutableArray *frames = [[[NSMutableArray alloc]init]retain];      for(int...

Lazy Loading UITableView Cell images in iPhone

L

.h – (void) loadImageInBackground:(NSArray *)urlAndTagReference ; – (void) assignImageToImageView:(UIImage *)img; .m – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0];...

Save and Load UIImage in Documents directory on iPhone

S

The following function saves UIImage in test.png file in the user Document folder: - (void)saveImage: (UIImage*)image { if (image != nil) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString* path = [documentsDirectory stringByAppendingPathComponent: [NSString stringWithString: @"test...

NSUserDefaults to save and retrieve the data in iPhone

N

In many applications we need to save the state of the application, in that case we can use NSUserDefaults. Lets start with saving the data into NSUserDefaults. We can save small amount of data in NSUserDefaults such as username, high scrore, etc. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:@”username” forKey:@”UserName”]; This is...

How to dial phone number programatically in iPhone / xCode?

H

UIDevice *device = [UIDevice currentDevice]; if ([[device model] isEqualToString:@”iPhone”] ) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@”tel:130-032-2837″]]]; } else { UIAlertView *Notpermitted=[[UIAlertView alloc] initWithTitle:@”Alert” message:@”Your device doesn’t support this feature.”...

“how to find Image size for a url in iPhone”

&

float size =  [UIImageJPEGRepresentation(Image,0.9) length]/1024.0/1024.0;
//in above line  Image is your image name
//NSLog(@”File Size : %f”, size);
 
if (size == 0)
{
UIImage *imagenew = [UIImage imageNamed”img-not-available.jpg”];
[ImageButton setImage:imagenew forState:UIControlStateNormal];
}
else
[ImageButton setImage:Image forState:UIControlStateNormal];
 

Category