मुझे यह जांचने में सक्षम होना चाहिए कि क्या मैंने उद्देश्य-सी में पहले से ही एक चर जारी किया है। मैं जांच का प्रयास करता है, तो यह शून्य करने के लिए बदल:मैं कैसे जांच सकता हूं कि कोई ऑब्जेक्ट जारी किया गया है या नहीं?
//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, 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
वहाँ अगर यह पुनः आवंटित की जाती है की जाँच करने के लिए किसी भी आसान रास्ता नहीं है?
क्या आप पूछ हो रहे हैं, तो वस्तु जारी की गई है नहीं है, बल्कि अगर यह पुनः आवंटित की जाती किया गया है। – PengOne
संभावित डुप्लिकेट [कैसे निर्धारित किया जाए कि मेरे पास जारी ऑब्जेक्ट के लिए पॉइंटर है?] (Http://stackoverflow.com/questions/12280799/how-to-determine-if-i-have-a-pointer-to-released -object) – OrangeDog