iphone - Passing a nil object to a function -
I was thinking that the purpose is to look at any probing that by calling the indicator function for an object The first is zero.
For example, I have a
myObject * ptr; and start
ptr = zero; and call
[my myfunction: ptr]; Where my function is my own function and does not check to see that the object is zero I have heard somewhere that the objective will not call the function if it is zero? Is this true and will my code be safe?
I am asking because I am implementing a universal application, and there is a UIView example which will only work for the iPad. But, I call many functions for this view, and to see if there is an iPad before calling this function, instead of checking the status, it would be nice if I set the view to zero I can if it is an iPhone.
In addition, if the interface creator has allocated the object and I have set the decisive to zero, can there be a memory leak or do the manufacturer have to remove the object?
Thank you
You always have a zero argument Can provide a method along with it, but I think you may have a misconception about the message about zero .
MyClass * object = zero; [Object doSomething]; // nothing, because the object is zero object [[MyClass alloc] init]; [Object doSomething]; // something, because the object indicates for an example Displaying zero as an argument:
NSMutableDictionary * myDict = [NSMutableDictionary dictionary]; [MyDict Set Object: @ "Price 1" for: @ "Key 1"]; [MyDict Set Object: Key for Zero: @ "Key 1"]; // Completely valid // myDict "key 1" is empty after setting the value to MyDict = zero; [MyDict Set Object: @ "Price 1" for: @ "Key 1"]; // nothing happen! In the above cases, the object and myDict are & ldquo; Receiver & rdquo; Is called. When the receiver is zero , no action is taken. It is quite different compared to other programming languages, for example, the following is not valid in C ++:
MyClass * object = NULL; Object & gt; DoSomething (); // Oops, this is not allowed
Comments
Post a Comment