iphone - MKAnnotation protocol -


im currrently going through geolocation tutorial adopts mkannotation protocol class.

the tutorial suggests create following methods in theannotation.h class

+ (id)annotationwithcoordinate:(cllocationcoordinate2d)coord;  - (id)initwithcoordinate:(cllocationcoordinate2d)coord; 

and in implementation

  + (id)annotationwithcoordinate:(cllocationcoordinate2d)coord {  return [[[[self class] alloc] initwithcoordinate:coord] autorelease];   }   - (id)initwithcoordinate:(cllocationcoordinate2d)coord {     if ( self = [super init] ) {     self.coordinate = coord; } return self; 

}

the second method called in viewcontroller

  theannotation *annotation = [[simpleannotation alloc] initwithcoordinate:coords]; 

i understand second method im puzzled inclusion of first. class method isn't called @ other place in example tutorial , im struggling understand why use class method in case.

you can omit class method in cases useful because provides mechanism create 'temporary' annotation autoreleased. of course can manually, class method way of convenience in case.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -