langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
8
Task/Search-a-list/Objective-C/search-a-list-1.m
Normal file
8
Task/Search-a-list/Objective-C/search-a-list-1.m
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
NSArray *haystack = [NSArray arrayWithObjects:@"Zig",@"Zag",@"Wally",@"Ronald",@"Bush",@"Krusty",@"Charlie",@"Bush",@"Bozo",nil];
|
||||
for (id needle in [NSArray arrayWithObjects:@"Washington",@"Bush",nil]) {
|
||||
int index = [haystack indexOfObject:needle];
|
||||
if (index == NSNotFound)
|
||||
NSLog(@"%@ is not in haystack", needle);
|
||||
else
|
||||
NSLog(@"%i %@", index, needle);
|
||||
}
|
||||
10
Task/Search-a-list/Objective-C/search-a-list-2.m
Normal file
10
Task/Search-a-list/Objective-C/search-a-list-2.m
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
NSArray *haystack = [NSArray arrayWithObjects:@"Zig",@"Zag",@"Wally",@"Ronald",@"Bush",@"Krusty",@"Charlie",@"Bush",@"Bozo",nil];
|
||||
id needle;
|
||||
NSEnumerator *enm = [[NSArray arrayWithObjects:@"Washington",@"Bush",nil] objectEnumerator];
|
||||
while ((needle = [enm nextObject]) != nil) {
|
||||
int index = [haystack indexOfObject:needle];
|
||||
if (index == NSNotFound)
|
||||
NSLog(@"%@ is not in haystack", needle);
|
||||
else
|
||||
NSLog(@"%i %@", index, needle);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue