Home › Forums › OpenEars › hypothesis for multiple string match › Reply To: hypothesis for multiple string match
January 20, 2014 at 1:29 am
#1019794
davestrand
Participant
Okee dokes, hello again. My beer function helped me sleep on it, but I’m still missing something. Here’s some of my code I’m working on.
objectsInRoom = [playerIsNowAt objectForKey:@"ObjectsInLocation"]; //Bringing objects based on location
NSLog(@"Here are objects in room - %@", objectsInRoom); //logged below
//Failed experiments
//NSArray *objectWords = [objectsInRoom allKeys];
//NSString *objectString = [NSString stringWithFormat:@"%@",objectWords];
//NSArray *spokenWords = [hypothesis componentsSeparatedByString:@" "];
//NSString *spokenString = [NSString stringWithFormat:@"%@",spokenWords];
//if([hypothesis isEqualToString:@"BEER"]) { //only works if they just say BEER
if ([hypothesis rangeOfString:@"BEER"].location != NSNotFound){ // ok but how do i make it search thru allkeys for my dictionary?? maybe the next room has WINE or MIMOSA.
NSLog(@"HOPE KEPT ALIVE");
}
THE LOG :
Here are objects in room – {
BEER = Beer;
PEANUTS = Peanuts;
READ = Menu;
}
So, as you see I can seem to pull single words in using Range, but am stuck on returning a value based on the dictionary.
Other related code.. in .h
@property (copy, nonatomic) NSDictionary *objectsInRoom;
in .m
@synthesize objectsInRoom; //hm, I think i’m supposed to not synthesize these days and use that underscore thingy?
I’ve only been coding for a few months, so understanding is appreciated.