设置:有一个UITableView显示美国高尔夫球场的名称、街道、州等。
UITableView's数据源是NSMutableArray我班级中的一个对象,GolfCourse名为allGolfCourses.
现在我想删除所有西海岸高尔夫球场allGolfCourses并创建一个新的array名为eastCoastGolfCourses. 我有另一个NSArray与string objects所有西海岸州(缩写)有关,westCoastStates但很难将这两者联系起来。
如何遍历 allGolfCourses 并删除在 westCoastStates数组中找到状态缩写的所有对象?
westCoastStates 数组:
self.westCoastStates = [NSMutableArray arrayWithObjects:
@"CH",
@"OR",
@"WA",
nil];
高尔夫球场.h
@interface GolfCourse : NSObject
@property (nonatomic, strong) NSString *longitude;
@property (nonatomic, strong) NSString *latitude;
@property (nonatomic, strong) NSString *clubName;
@property (nonatomic, strong) NSString *state;
@property (nonatomic, strong) NSString *courseInfo;
@property (nonatomic, strong) NSString *street;
@property (nonatomic, strong) NSString *city;
@property (nonatomic, strong) NSString *clubID;
@property (nonatomic, strong) NSString *phone;
@end
注意:NSString *state; 包含州缩写,例如:FL
我知道如何使用单个参数来执行此操作,但不知道如何检查westCoastStates数组中的所有字符串。希望你能帮忙。