Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 未在类中设置另一个类中对象的值_Objective C_Set - Fatal编程技术网

Objective c 未在类中设置另一个类中对象的值

Objective c 未在类中设置另一个类中对象的值,objective-c,set,Objective C,Set,在类中,我需要从另一个视图为标签设置值 要赋值的第一个类: #import "ViewDetailPoinmap.h" ... NSLog(@"On a cliqué sur : %@",[NSNumber numberWithInt:sender.tag]); //On a cliqué sur : 2130 ViewDetailPoinmap *detailPoint = [[ViewDetailPoinmap alloc] init]; detailPoint.idPoint = [

在类中,我需要从另一个视图为标签设置值

要赋值的第一个类:

#import "ViewDetailPoinmap.h"
...

NSLog(@"On a cliqué sur : %@",[NSNumber numberWithInt:sender.tag]);
//On a cliqué sur : 2130

ViewDetailPoinmap *detailPoint = [[ViewDetailPoinmap alloc] init];
detailPoint.idPoint =  [NSNumber numberWithInt:sender.tag];
detailPoint.txtIDPoint.text = [NSString stringWithFormat:@"%@", [NSNumber numberWithInt:sender.tag]];
另一个类(ViewDetailPoinmap.h):

(ViewDetailPoinmap.m)


问题出在哪里?

在哪里创建
txtIDPoint
实例?您已经显示了尝试设置其文本的位置,但除非您初始化了标签本身,否则标签本身将为
nil
,这与您描述的症状一致。

您将属性标记为
assign
,并且它引用了第一类中的变量。可能该变量已经自动释放

detailPoint.idPoint =  [NSNumber numberWithInt:sender.tag]; // here you assign 

尝试在此处更改
@属性(非原子,赋值)NSNumber*idPoint分配给保留

文本没有问题。NSlog返回值(null)=>NSlog(@“在到达后的第二页尾点:%@”,idPoint);我不明白。您希望我在第一个类中创建一个实例吗?别忘了在dealloc中释放它(如果未启用ARC的话)!已经有[detailPoint发布];在分配值的方法中,我指的是保留值的释放property@AlexandreOuicher,您是否尝试在此处更改属性(非原子,赋值)NSNumber*idPoint分配以保留?让我们
...
@synthesize txtIDPoint;
@synthesize idPoint;


...

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSLog(@"ON arrive sur la page détail du point : %@",idPoint);
    //ON arrive sur la page détail du point : (null)

}
detailPoint.idPoint =  [NSNumber numberWithInt:sender.tag]; // here you assign