ios - Need assistance regarding @property concepts -


i working on corelocation , worte code

cllocationmanager *locationmanager = [[cllocationmanager alloc]init];     [locationmanager setdesiredaccuracy:kcllocationaccuracybestfornavigation];     [locationmanager setdelegate:self];     //[locationmanager setdistancefilter:0.0f];     [locationmanager startupdatinglocation];   -(void)locationmanager:(cllocationmanager *)manager didupdatelocations:(nsarray *)locations {      .     .     . } 

but delegate method not working, after 15 - 20 realised didn't create property of cllocationmanager @property (strong, nonatomic) cllocationmanager *locationmanager;

after doing worked fine, no issues. have experienced several times, time things work without creating @property , thing absolutely don't work without creating @property.

i know @property @synthesize create getter setter automatically include memory management prevent object destroy immediately, how sometime code works without creating @property?

edit:

i create new class name myclass

myclass.h:

@interface myclass : nsobject -(void)givemeok; @end 

myclass.m

@implementation myclass  -(void)givemeok {     nslog(@"its ok."); }  @end 

in view controller wrote corelocation code, in viewdidload did this:

. . . myclass *myclassobj = [[myclass alloc]init];      [myclassobj givemeok]; . . . 

and in console its ok. print successfully, worked without @property.

i think issue might having when don't "create property" using local variable. difference being once scope of variable has ended (typically end of method created in), released, delegate methods location manager ones wont called (because there no longer object call them, though delegate still exists)

by creating property increasing objects retain count, making sure life of object lasts beyond method created in

update:

you update makes me think i'm right. problem not understanding lifecycle of object: local variable exists scope created in (so example: after viewdidload run, myclassobj doesn't exist more). needs continue work after method (i.e. location manager polls hardwares gps), need property because needs retained long enough work. job (like example class, performs log , returns, i.e. nothing asynchronous) local variable fine


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -