Re: More on drawRect not getting called
Re: More on drawRect not getting called
- Subject: Re: More on drawRect not getting called
- From: Andy Lee <email@hidden>
- Date: Sun, 24 Jul 2011 16:18:17 -0400
On Jul 24, 2011, at 4:01 PM, Tom Jeffries wrote:
> On Sun, Jul 24, 2011 at 12:12 PM, Andy Lee <email@hidden> wrote:
> You should know that it is most certainly possible to use that syntax with a variable. For example:
>
> NSString *myString = @"abc"; // <== a variable
> NSString *newString = [myString copy]; // <== a message send
>
> You can send messages to both classes and instances of classes. If you are not clear about the difference between a class and an instance, let us know now so we can proceed on the same page.
>
>
> OK, we're each half right- myString in this case is a function, not a class, but I would question calling it a variable.
No, myString is a variable. It is a variable of type NSString*. "NSString" is the name of a class. "copy" is the name of a method implemented by NSString, and used here as the name of a message sent to an instance of the class NSString.
I suggest you review the docs on the Objective-C language. Apologies, I don't have time at the moment to find a link, but you really must grasp the basics of the language and terminology, if not to help you now then definitely in the (possibly near) future. You *must* be able to read the two lines above and without any question pick out which is a variable, which is a class name, which is a message send, etc.
In Objective-C we distinguish between methods (be they instance methods or class methods) and functions, by which we usually mean C functions. It will serve you well to remember this when communicating with Cocoa developers.
> Maybe I'm old fashioned, but I think it's important to distinguish between information (variables) and operations (functions).
I'm probably about as "old-fashioned" as you. :)
> That is one reason why I'm less than completely enthusiastic about Objective C syntax and Cocoa conventions.
All of the Objective-C syntax we've looked at is perfectly clear about which symbols refer to variables, which to methods, and which to messages. Some people don't like the way it does it, but that is different from saying it doesn't make the distinctions.
Study the language documentation and if you have more questions about the *language* (as opposed to the frameworks) the objc-language list is probably more appropriate <email@hidden>. Typical stumbling blocks for newcomers are: the method syntax that intersperses arguments with parts of the method name; and how class methods work (they are not like static methods in Java).
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden