PDA

View Full Version : terminating due to uncaught exception




andyiapan
Nov 26, 2010, 06:21 AM
NSArray *db1;


.....

- (void)viewDidLoad
{
....

db1 = [newStr componentsSeparatedByString:@" "];


}
- (IBAction) button1:(id)sender{

queue1.titleLabel.text = [db1 objectAtIndex: 3];

}

just a simple call, why terminate, HELP thanks><



robbieduncan
Nov 26, 2010, 06:38 AM
Read the Memory Management Guide (http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html). All of it. If you don't understand something stop until you do.

You are assigning an autoreleased value to db1 so you cannot expect that to exist at some undefined point in the future.

andyiapan
Nov 26, 2010, 01:09 PM
Thanks, assigning an autoreleased value? i still can't find out reason,
can explain to me><

Many Thanksss

Read the Memory Management Guide (http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html). All of it. If you don't understand something stop until you do.

You are assigning an autoreleased value to db1 so you cannot expect that to exist at some undefined point in the future.

robbieduncan
Nov 26, 2010, 01:11 PM
Thanks, assigning an autoreleased value? i still can't find out reason,
can explain to me><

Many Thanksss

That is the reason. If you don't know what that means you need to go back to basics. Did you read the document I linked to? Have you read the Objective-C guide on the developer site? If you don't know what that means you don't have the most basic knowledge you need.