Johnny Chen | 86f4f31 | 2011-05-10 21:36:11 +0000 | [diff] [blame] | 1 | #import <Foundation/Foundation.h> |
| 2 | |
| 3 | NSMutableArray * |
| 4 | GetArray () |
| 5 | { |
| 6 | static NSMutableArray *the_array = NULL; |
| 7 | if (the_array == NULL) |
| 8 | the_array = [[NSMutableArray alloc] init]; |
| 9 | return the_array; |
| 10 | } |
| 11 | |
| 12 | int |
| 13 | AddElement (char *value) |
| 14 | { |
| 15 | NSString *element = [NSString stringWithUTF8String: value]; |
| 16 | int cur_elem = [GetArray() count]; |
| 17 | [GetArray() addObject: element]; |
| 18 | return cur_elem; |
| 19 | } |
| 20 | |
| 21 | const char * |
| 22 | GetElement (int idx) |
| 23 | { |
| 24 | if (idx >= [GetArray() count]) |
| 25 | return NULL; |
| 26 | else |
| 27 | return [[GetArray() objectAtIndex: idx] UTF8String]; |
| 28 | } |