89. Objective-C
:
Create
NSArray
//
方法一:
Creates
an
NSArray
with
one
object
NSArray
*
myArray
=
[NSArray
arrayWithObject:@"foo"];
//
Creates
an
NSArray
with
multiple
objects.
Don't
forget
to
add
nil
as
the
last
object
NSArray
*
myArray2
=
[NSArray
arrayWithObjects:@"foo",@"bar",@"baz",nil];
//
Creates
an
NSArray
from
another
NSArray
NSArray
*
myArray3
=
[NSArray
arrayWithArray:
myArray2];
//
This
will
create
an
NSArray
from
data
on
iCodeBlog.
Go
ahead
and
try
it
out,
this
file
exists
on
our
servers
and
contains
valid
data.
NSArray
*
myArray4
=
[NSArray
arrayWithContentsOfURL:[NSURL
URLWithString:@"http://
icodeblog.com/uploads/foo.plist"]];
//方法二:
NSArray
*
foo
=
[[NSArray
alloc]
initWithObjects:@"foo",@"bar",@"baz",nil];
Potato Hwang @ Taiwan Taipei 2012 89
Sunday, October 28, 12