Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.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
Ios 获取EXC\u错误访问(代码=2,地址=0x0)错误_Ios_Objective C_Exc Bad Access - Fatal编程技术网

Ios 获取EXC\u错误访问(代码=2,地址=0x0)错误

Ios 获取EXC\u错误访问(代码=2,地址=0x0)错误,ios,objective-c,exc-bad-access,Ios,Objective C,Exc Bad Access,我的代码中有一个错误的访问权限,我不知道为什么 这是我的密码 -(IBAction)datePickerValueChanged:(UIDatePicker *)sender{ myDatePicker = [[myDatePickerView subviews] lastObject]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setLocale:se

我的代码中有一个错误的访问权限,我不知道为什么

这是我的密码

-(IBAction)datePickerValueChanged:(UIDatePicker *)sender{
    myDatePicker = [[myDatePickerView subviews] lastObject];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setLocale:sender.locale];
    [dateFormatter setDateStyle:NSDateFormatterMediumStyle];
    activeTextField = (UITextField *) [self.view viewWithTag: *(tag)];
    [activeTextField setText:[dateFormatter stringFromDate:[sender date]]];
}
附言:我在@interface中创建了activeTextField属性,如下所示

@property(非原子,强)UITextField*activeTextField

我合成了它


@activeTextField

尝试替换此行

activeTextField = (UITextField *) [self.view viewWithTag: *(tag)];


这是什么?
*(标记)
?它在哪一行断开EXACLTY,什么是*(标记)?标记是UIView的属性,@property(非原子)NSInteger*标记;它打开:activeTextField=(UITextField*)[self.view viewWithTag:*(tag)];为了澄清@Bhumeshwer的答案,在计算表达式前面放置一个星号将取消对指针的引用。由于标记很可能是一个整数(而不是指向整数的指针),因此取消对它的引用将产生一些恶劣的副作用int@iOSMaster:
NSInteger
不是一个对象;它是一个32位或64位的类型定义,具体取决于处理器。
activeTextField = (UITextField *) [self.view viewWithTag: tag];//tag should be an integer