2
如何測試objc_getAssociatedObject
是nil
?以下說元素不是nil
,但關聯的對象從來沒有被設置過,也沒有被訪問過。if(objc_getAssociatedObject(self,&Key))對於零對象返回true
static char orderedElementKey = 11;
if (objc_getAssociatedObject(self, &orderedElementKey) != nil)
{
NSLog(@"element is not nil");
return objc_getAssociatedObject(self, &orderedElementKey);
}
NSLog(@"elelement was nil !");
什麼是被返回的對象? –
NSStringFromClass print(null) –
它適用於我,什麼是orderedElementKey? – Fr4ncis