开发者

Cannot pass string through classes

开发者 https://www.devze.com 2023-01-19 05:27 出处:网络
//Initialize the detail view controller and display it. OrderDetailsView *dvController = [[OrderDetailsView alloc] initWithNibName:@\"OrderDetailsView\" bundle:[NSBundle mainBundle]];
//Initialize the detail view controller and display it.
OrderDetailsView *dvController = [[OrderDetailsView alloc] initWithNibName:@"OrderDetailsView" bundle:[NSBundle mainBundle]];
dvController.selectedOrder = (@"%@",selectedOrder);
[self.navigationController pushViewController:dvController animated:YES];
[dvController release];
dvController = nil;

What seems to be the problem ?

i am getting the error: object cannot be set - either readonly property or no开发者_StackOverflow setter found


In the OrderDetailsView.h add the following :

@property (nonatomic, retain) [TYPEOFSELECTEDORDER]* selectedOrder;

And in the OrderDetailsView.m :

@synthesize selectedOrder;


To help you, we would need the OrderDetailsView header content (especially the part where selectedOrder appears).

Given the error, i would say that you did not declare the property in the header like this :

@property(retain) NSString *selectedOrder;

Then you can either define the setter and getter for this property yourself in the implementation file (OrderDetailsView.m) like this :

- (NSString *) selectedOrder {
  // your getter implementation here
}
- (void) setSelectedOrder:(NSString *) value {
  // your setter implementation here
}

Or you can use @synthesize selectedOrder; at the top of your class implementation. @synthesize will handle all the memory stuff for you, given the information you provide in the @property

0

精彩评论

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