Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.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 不兼容的整数到指针转换“;int";至参数类型为";id";_Ios_Objective C_Xcode - Fatal编程技术网

Ios 不兼容的整数到指针转换“;int";至参数类型为";id";

Ios 不兼容的整数到指针转换“;int";至参数类型为";id";,ios,objective-c,xcode,Ios,Objective C,Xcode,我试图为解析用户对象的“活动”键字段分配布尔值,但由于某种原因,当试图将用户[@“活动”]设置为真正的布尔值时,我收到错误“不兼容的整数到指针转换”int“到参数类型“id”。这仅在将其设置为TRUE时发生,将其设置为FALSE不会导致错误。此外,将其设置为0也可以,但1会出错。我不知道为什么我尝试分配哪个布尔值很重要。任何想法都将不胜感激。谢谢您不能将BOOL添加到(有效的字典)对象中。用户对象希望接收另一个对象,因此您的BOOL应该包装到一个NSNumber实例中: - (void) ch

我试图为解析用户对象的“活动”键字段分配布尔值,但由于某种原因,当试图将用户[@“活动”]设置为真正的布尔值时,我收到错误“不兼容的整数到指针转换”int“到参数类型“id”。这仅在将其设置为TRUE时发生,将其设置为FALSE不会导致错误。此外,将其设置为0也可以,但1会出错。我不知道为什么我尝试分配哪个布尔值很重要。任何想法都将不胜感激。谢谢

您不能将BOOL添加到(有效的字典)对象中。用户对象希望接收另一个对象,因此您的BOOL应该包装到一个
NSNumber
实例中:

 - (void) changeState
  {

    if ([_buttonChangeState.title isEqual: @"Active"])
    {
        PFUser *user = [PFUser currentUser];
        user[@"active"] = FALSE;
        user[@"party"] = @"";
        [user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error)
        {
            if (error)
            {
                _statusFailed = [[UIAlertView alloc]initWithTitle:@"" message:@"Status Change       Error, Try Again" delegate:self cancelButtonTitle:@"Retry" otherButtonTitles:@"Close", nil];
                _statusFailed.cancelButtonIndex = 0;
                [self.view addSubview:_statusFailed];
            }
            else
            {
                [_buttonChangeState setTitle:@"Taking A Break"];
            }
        }];
    }
    if ([_buttonChangeState.title isEqual:@"Taking A Break"])
    {
       PFUser *user = [PFUser currentUser];
       user[@"active"] = TRUE;
       [user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) 
        {
           if(error)
            {
                [self.view addSubview:_statusFailed];
            }
        }];
    }
}

这适用于是(真)和否(假)情况



此外,您不应该将
\u statusFailed
添加为子视图。调用其
show
方法来显示警报视图。

您不能将布尔添加到(有效的字典)对象中。用户对象希望接收另一个对象,因此您的BOOL应该包装到一个
NSNumber
实例中:

 - (void) changeState
  {

    if ([_buttonChangeState.title isEqual: @"Active"])
    {
        PFUser *user = [PFUser currentUser];
        user[@"active"] = FALSE;
        user[@"party"] = @"";
        [user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error)
        {
            if (error)
            {
                _statusFailed = [[UIAlertView alloc]initWithTitle:@"" message:@"Status Change       Error, Try Again" delegate:self cancelButtonTitle:@"Retry" otherButtonTitles:@"Close", nil];
                _statusFailed.cancelButtonIndex = 0;
                [self.view addSubview:_statusFailed];
            }
            else
            {
                [_buttonChangeState setTitle:@"Taking A Break"];
            }
        }];
    }
    if ([_buttonChangeState.title isEqual:@"Taking A Break"])
    {
       PFUser *user = [PFUser currentUser];
       user[@"active"] = TRUE;
       [user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) 
        {
           if(error)
            {
                [self.view addSubview:_statusFailed];
            }
        }];
    }
}

这适用于是(真)和否(假)情况


此外,您不应该将
\u statusFailed
添加为子视图。调用其
show
方法来显示警报视图

user[@"active"] = [NSNumber numberWithBOOL:YES];