NSArray的创作带有可变参数列表 [英] NSArray creation with variable argument lists

查看:116
本文介绍了NSArray的创作带有可变参数列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个数组简便方法接受一个逗号分隔与结束对象列表。

This array convenience method takes a comma-separated list of objects ending with nil.

myArray = [NSArray arrayWithObjects:aDate, aValue, aString, nil];

什么是目的的

推荐答案

空终止的可变参数列表的va_list S,继续走参数列表中,直到他们遇到一个占位符或定点,这是

Null terminated variable argument lists, or va_lists, keep walking the list of arguments until they encounter a placeholder or sentinel, which is nil.

由于该方法无法知道多少个参数你逝去的,它需要的定点()来告诉列表的结束位置的方法。

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.

这篇关于NSArray的创作带有可变参数列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆