Setup: Have a UITableView which shows US golf courses with name, street, state etc.
UITableView's data source is a NSMutableArray of objects from my class GolfCourse called allGolfCourses.
Now I like to remove all west coast golf courses from allGolfCourses and create a new array called eastCoastGolfCourses. I have another NSArray with string objects of all west coast states (Abbreviations) called westCoastStates but having a hard time connecting these two.
How do I iterate through allGolfCourses and remove all objects which have a state Abbreviations found in westCoastStates array?
westCoastStates Array:
self.westCoastStates = [NSMutableArray arrayWithObjects:
@"CH",
@"OR",
@"WA",
nil];
GolfCourse.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
Note: NSString *state; contains the state abbreviation for example: FL
I know how to do this with a single argument but don't know how to check against all strings from westCoastStates array. Hope you can help.
whileand continue from there. (Or actuallyforwould be better.)NSArray, both for performance and readability purposes.