开发者

iPhone, Need to check if values have changed before I update my database?

I've gone for a simple approach, I've created some NSString variables w开发者_JAVA百科hich I set when the view load...

strKeptDesc = txtDescription.text;

NSLog(@"KDesc  =#%@# CDesc  =#%@#",strKeptDesc, txtDescription.text);

Which works as excepted and output the values you'd expect.

However in my db commit function, when I check the variables I get errors...

NSMethodSignature: 0x5c3fa80># CDesc  =#Gas bill3#
Program received signal:  “EXC_BAD_ACCESS”.

In my h file I have

NSString *strKeptDesc;
}

@property (nonatomic, retain) NSString *strKeptDesc;

I synthesize too.


strKeptDesc = txtDescription.text;

in this line you simply assign a string value to your iVar and your accessor methods do not get called - so if you're assigning autoreleased string it may be released and become invalid. You must write

self.strKeptDesc = txtDescription.text;

instead, so strKeptDesc will be retained in setter and remain valid outside the current method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜