這是我的代碼:試圖找出爲什麼我的應用程序崩潰?
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"location for url1 B %@", locationForURL1);
if ((alertView.tag <= 3) && (alertView.tag >= 1)) {
if (buttonIndex == 1) {
NSLog(@"location for url1 %@", locationForURL1);
的locationForURL1曾在它的代碼的其餘部分,直到這一點的條目,但它在第一次的NSLog這裏crahes。
所以我加了nszombieenabled並得到message sent to deallocated instance 0x508eda0
。我如何使用它來找出我的問題?我聽說有人說把它放在init方法中,這讓我困惑,因爲我找不到init方法。我從來沒有做過這樣的調試。
編輯:
我是這樣分配的:
@interface RewriteViewController : UIViewController <MPMediaPickerControllerDelegate> {
NSString *locationForURL1;
}
@property (nonatomic,retain) NSString *locationForURL1;
我覺得這件事情做的self.VARIABLE的事情,但我永遠無法弄清楚當我打算把自己。如果我打算換一些別的東西。
這是我必須locationForURL1引用的.m文件:
@synthesize locationForURL1;
-(void)getWeatherLocation {
if (currentResult == 1) {
self.locationForURL1 = locationTown;
locationForURL1 = [locationForURL1 stringByAppendingString:@","];
locationForURL1 = [locationForURL1 stringByAppendingString:locationCountry];
}
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if ((alertView.tag <= 3) && (alertView.tag >= 1)) {
if (buttonIndex == 1) {
NSLog(@"location for url1 %@", self.locationForURL1);
self.weatherFullURL = [self.weatherFullURL stringByAppendingString:self.locationForURL1];
}
}
}
-(void)dealloc {
[locationForURL1 release];
[super dealloc];
}
你如何分配`locationForURL1`? – aqua 2011-02-05 02:46:40