将数据传递到两个 viewController 之间的 NSMutablearrays,IOS 4.3
我正在尝试将 NSMutablearray 中的对象传递给另一个视图的 NSmutableArray
我一直在寻找相关问题,但无法弄清楚出了什么问题。
我的视图切换正确,但它没有传递我的 NSmutable 数组视图中的对象,
- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath {
StartHuntViewController *startHuntController = [[StartHuntViewController alloc] initWithNibName:@"StartHuntView" bundle:nil];
startHuntController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:startHuntController animated:YES];;
startHuntController.forStandButton = [stands objectAtIndex:indexPath.row];// doesnt work
// startHuntController.standLocation.text=[stands objectAtIndex:indexPath.row]; // this works
[startHuntController release];
[self.mytableView reloadData];
}
我试图传递数据,
.h file
@interface StartHuntViewController : UIViewController<UIApplicationDelegate,CLLocationManagerDelegate,CoreLocationControllerDelegate> {
NSMutableArray *forStandButton;
}
@property (nonatomic, assign)NSMutableArray *forStandButton;
.m file
@synthesize forStandButton;
我应该做什么?我想代码没有什么问题?
I am trying to pass an object in NSMutablearray to another view's NSmutableArray
I have been looking related question but couldnt figure out whats wrong.
my view switches correctly but it doesnt pass the object in my NSmutable array
- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath {
StartHuntViewController *startHuntController = [[StartHuntViewController alloc] initWithNibName:@"StartHuntView" bundle:nil];
startHuntController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:startHuntController animated:YES];;
startHuntController.forStandButton = [stands objectAtIndex:indexPath.row];// doesnt work
// startHuntController.standLocation.text=[stands objectAtIndex:indexPath.row]; // this works
[startHuntController release];
[self.mytableView reloadData];
}
view i am trying to pass data is
.h file
@interface StartHuntViewController : UIViewController<UIApplicationDelegate,CLLocationManagerDelegate,CoreLocationControllerDelegate> {
NSMutableArray *forStandButton;
}
@property (nonatomic, assign)NSMutableArray *forStandButton;
.m file
@synthesize forStandButton;
what should i do ? i guess there is nothing wrong with code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里有很多问题,首先看一下:
为什么财产不保留?
there are many issues here, for first look :
why property is not retain?
将分配更改为保留,移动行
startHuntController.forStandButton = [stands objectAtIndex:indexPath.row];
changed assign to retain, move the line
startHuntController.forStandButton = [stands objectAtIndex:indexPath.row];
您需要在属性声明中使用retain。由于
forStandButton
是第二个视图的属性,因此您需要确保它已被设置。如果您为其创建一个 setter (setForStandButton
),则可以在 setter 方法中放置一个断点。一旦您确认 setter 被调用,请确保它被保留足够长的时间以使其有用。You need to use retain in the property statement. Since
forStandButton
is a property of the second view, you want to make sure it is getting set. If you create a setter (setForStandButton
) for it, you can put a break point in the setter method. Once you have confirmed that the setter is being called, make sure it is being retained long enough to be useful.