Sujeev's Tech Blog

Friday, October 21, 2011

Great iPhone web-services tutorial

http://www.iphonedevsdk.com/forum/iphone-sdk-tutorials/76730-webservice-how.html

Sunday, March 06, 2011

iOS and Google maps

If you want to get a address using GPS coordinates, you an use MKReverseGeocoder to obtain that info, however if you want to get a GPS coordinate using a address, you have to use JSON to access the data from google maps API.

Tuesday, February 22, 2011

Private retained variables.

Normally if you want to retain a variable, we have to specify that in the .h file.

ex:

@interface ....
{
NSMutableArray *listItems;
.
.
.
}

@property (nonatomic, retain) NSMutableArray *listItems;
.
.
.
@end

instead, we can specify this on the .m

Ex:

on the .h file

@interface viewMain: ...
{
NSMutableArray *listItems;
.
.
.
}

.
.
.
@end

on the .m file

@interface viewMain ()

@property (nonatomic, retain) NSMutableArray *listItems;
@end

@implementation
.
.
.

Tuesday, January 18, 2011

xCode iPhone self initiating variables.

lets say, I have a variable defined in .h, before using it on the .m file I have to initiate it, normally the initiating code is inserted some where on viewDidLoad if the variable is used through out the .m, however the dis-advantage with this format is that the variable will be initiated all the time the view is loaded, even when the variable is never used.

however with the following method, the variable is initiated on the first instance that its actually referred, there by if the variable is not used in a specific run the variable wont be initiated.

on the .h file

@interface ... {
CLLocationManager *locMan;
.
.
.
}

.
.
.
@property (nonatomic, retain) CLLocationManager *locMan;
.
.
.
@end

on the .m file

-(CLLocationManager *)locMan{
if (locMan != nil) {
return locMan;
}
locMan = [[CLLocationManager alloc] init];
locMan.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
locMan.delegate = self;
return locMan;
}

Monday, January 03, 2011

UIAlertView and its delegate

Following is the normal use of UIAlertView

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:msgTitle message:soapResults delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];

but lets say if we want to do some processing after a UIAlertView is dismissed, then to accomplish this,

first add a UIAlertViewDelegate to the viewController.
second use the following.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:msgTitle message:soapResults delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert setTag:127];
[alert show];

[alert release];

- (
void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
    if ([alertView tag] == 127) {    
if (buttonIndex == 0) {
// do stuff
}
}
}


in the above code note the UIAlertView tag used as a identifier when there are more than one UIAlertViews

Wednesday, October 27, 2010

MFMail for the iOS

a great example

http://www.screencast.com/users/AppShop/folders/Jing/media/e50794e7-6da4-4dfa-b75f-6df3b19681bf

NSObject based property release order

I guess this is valid not just for NSObject.

when releasing objects that are used within a class always use [super dealloc] as the last command.


ex:

[mylist release];
[plist release];
[super dealloc];

Monday, October 25, 2010

Typecasting in iOS

example:

@interface mytype : XYZtype {
}
.
.
.
mytype *abc = [some_function];

in the above syntax if some_function returns a type of XYZtype then the following is correct.

mytype *abc = (mytype *)[some_function];