我需要能够检查我是否已经在
objective-c中发布了一个变量.我试过检查它是否变为null:
//Checks if buildview is null and returns respective output if(BuildView == NULL) NSLog(@"Build View Value (pointer): Null"); else NSLog(@"Build View Value (pointer): Not Null"); //allocates memory and initalizes value BuildView = [[UIView alloc] initWithFrame:CGRectMake(0,10,10)]; //Checks if buildview is null and returns respective output again if(BuildView == NULL) NSLog(@"Build View Value (pointer): Null"); else NSLog(@"Build View Value (pointer): Not Null"); //Releases the view [BuildView release]; //Checks if buildview is null and returns respective output again if(BuildView == NULL) NSLog(@"Build View Value (pointer): Null"); else NSLog(@"Build View Value (pointer): Not Null");
结果是:
Build View Value (pointer): Null Build View Value (pointer): Not Null Build View Value (pointer): Not Null
有没有更简单的方法来检查它是否被解除分配?