This array convenience method takes a comma-separated list of objects ending with nil.
myArray = [NSArray arrayWithObjects:aDate, aValue, aString, nil];
What is the purpose of the nil?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Null terminated variable argument lists, or
va_lists, keep walking the list of arguments until they encounter a placeholder or sentinel, which isnil.Since the method has no way of knowing how many arguments you are passing, it needs the sentinel (
nil) to tell where the list ends.