What does aString and mask means?


#1

What does aString and mask means in NSString class reference?


#2

First, I need to ask a question: Have you been reading the Objective-C Programming book, and are now on this chapter?

The reason I ask is that your question would have been answered by now.

If not, then here is the answer to your question:

I assume you are talking about the following:

[code]+ (instancetype)stringWithString:(NSString *)aString

  • (NSString *)commonPrefixWithString:(NSString *)aString options:(NSStringCompareOptions)mask[/code]

Basically aString and mask are the names of the arguments for these methods, so stringWithString takes a NSString argument which is named aString.

Now, when you create your own methods, you can give the arguments any name you like, however it is best to give them names which have some relevance:
If your argument is a NSString then you would probably name it something like string, aString etc., or if your argument is a NSDictionary, then you would most likely call it dictionary.

I hope this helps,
Nick


#3

Hi, yes I’m reading the book and I’ve finished this chapter already. What do you think I’ve missed?


#4

Hi,

Unfortunately I am at work just now, and don’t have the book to hand, however I would say that there should be a discussion on method arguments and parameters most likely in Chapter 5: Functions, and possibly Chapter 12: Objects.

Nick