我想將NSSting調用爲void方法,但我得到了EXC_BAD_ACCESS錯誤。這會導致什麼?在另一個無效方法問題中調用NSString
我已經在btnPickerDoneTouchHandler中對NSLog進行了制動點(調試),但choiceList是空的。
.H:
@interface controlView : UIViewController{
NSString *choiceList;
}
.M:
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return [res count];
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
return [[res objectAtIndex:row]objectForKey:@"choice_name"];
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
choiceList = [NSString stringWithFormat:@"<r_PM act='closepos_choice' cl_choice='%d'/>", row];
NSLog(@"You have selected row %@", choiceList);
}
- (void)btnPickerDoneTouchHandler{
//I have put here the brakepoint.
NSLog(@"choiceList is %@", choiceList);
}
你使用ARC或手動內存管理? – CarlJ
使用ARC的同期嗎? –
如果您沒有使用ARC,請爲choiceList字符串進行屬性和合成。 – Smita