Can you please explain me exact difference between these two lines?
NSArray *foo = [NSArray arrayWithObjects:@\"hai\",@\"how\",@\"are\",@\"you\",nil];
NSArra
arrayWithObject
returns an autoreleased array so you do not have to worry about releasing it when you don't need it anymore (but if you store it in an instance variable, you should retain it to prevent the autorelease pool from freeing it). initWithObject
returns an array with a retain count of 1, i.e. you own the array and you must release it at some point to prevent memory leaks.
You might want to read this guide for more clarification.