开发者

String not receiving new value is always (null)

开发者 https://www.devze.com 2023-01-27 15:46 出处:网络
Weird thing is happening here. NSString *string = [powerPickerVC.powerList objectAtIndex:selRow]; NSLog(@\"powerPicker row = %@\", string); //this returns me the string from powerList

Weird thing is happening here.

NSString *string = [powerPickerVC.powerList objectAtIndex:selRow];
NSLog(@"powerPicker row = %@", string); //this returns me the string from powerList
repVC.selectedPower = string; //selectedPower doesn't receive the new value and returns (null)
NSLog(@"selectedPower = %@", repVC.selectedPower);

And repVC.selectedPower is always returning 开发者_运维百科(null)!

Just before that piece of code, I have this:

selectedRowPower = [powerPickerVC.powerPicker selectedRowInComponent:0];
repVC.selectedRowInObjectPicker = selectedRowPower;
NSLog(@"selectedRowInObjectPicker = %d", selectedRowPower);

And that works perfectly. selectedRowInObjectPicker is an NSInteger but if I'm able to set its value, why am I not being able to set selectedPower's value?

Yes, the object is synthesized and everything...


High chance that repVC is nil. Try to add breakpoint there and see.


Have you defined a method called -setSelectedPower: by any chance?


Use the [NSString stringWithString: ] to initialize strings.

In your case,

repVC.selectedPower = [[NSString stringWithString:string];

And ensure the receiver is a properly declared NSString as intended.

0

精彩评论

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