jjzjj

orderedElementKey

全部标签

ios - if(objc_getAssociatedObject(self, &Key)) 为 nil 对象返回 true

如何测试objc_getAssociatedObject是否为nil?下面说元素不是nil但关联的对象以前从未设置过也从未被访问过。staticcharorderedElementKey=11;if(objc_getAssociatedObject(self,&orderedElementKey)!=nil){NSLog(@"elementisnotnil");returnobjc_getAssociatedObject(self,&orderedElementKey);}NSLog(@"elelementwasnil!"); 最佳答案