Changeset 213 for apps/iphone/my.tel
- Timestamp:
- 01/29/09 16:18:27 (4 years ago)
- Location:
- apps/iphone/my.tel/trunk/Classes
- Files:
-
- 2 modified
-
KeywordViewController.h (modified) (1 diff)
-
KeywordViewController.m (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
apps/iphone/my.tel/trunk/Classes/KeywordViewController.h
r205 r213 37 37 - (void)storeKeyword:(NSDictionary *)aRec; // Could be a set of primary+secondaries 38 38 - (void)deleteKeywords:(NSDictionary *)aRec; 39 - (void)getValidKeywords ;39 - (void)getValidKeywords:(BOOL)fromNetwork; 40 40 41 41 @property (nonatomic, retain) NSMutableDictionary *validKeywordTypes; -
apps/iphone/my.tel/trunk/Classes/KeywordViewController.m
r205 r213 37 37 rowsToDelete = [[NSMutableDictionary dictionaryWithCapacity:5] retain]; 38 38 keywordTableHeight = kKRowHeight; 39 [self getValidKeywords ];39 [self getValidKeywords:FALSE]; 40 40 } 41 41 … … 273 273 274 274 - (void)fillValidKeywordsDict:(NSDictionary *)parsedJson { 275 if (!parsedJson)276 return;277 275 if (!self.validKeywordTypes) { 278 276 self.validKeywordTypes = [[NSMutableDictionary dictionaryWithCapacity:20] retain]; … … 280 278 [self.validKeywordTypes removeAllObjects]; 281 279 } 282 // TODO: Why do we check success here, and not in the record's fillServicesDict and fillLocationsDict? 283 if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 284 NSArray *keyTypeList = (NSArray *)[parsedJson valueForKey:@"validKeywordList"]; 285 NSDictionary *aKeyType; 286 for (aKeyType in keyTypeList) { 287 [self.validKeywordTypes setObject:(NSString *)[aKeyType objectForKey:@"displayText"] 288 forKey:(NSString *)[aKeyType objectForKey:@"shortForm"]]; 280 if (!parsedJson) { 281 // We're loading the data statically (not from the network) 282 self.validKeywordTypes = [NSMutableDictionary dictionaryWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] 283 stringByAppendingPathComponent:@"KeywordTypes.plist"]]; 284 } else { 285 if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 286 NSArray *keyTypeList = (NSArray *)[parsedJson valueForKey:@"validKeywordList"]; 287 NSDictionary *aKeyType; 288 for (aKeyType in keyTypeList) { 289 [self.validKeywordTypes setObject:(NSString *)[aKeyType objectForKey:@"displayText"] 290 forKey:(NSString *)[aKeyType objectForKey:@"shortForm"]]; 291 } 292 } else { 293 [Keyword throwJsonErrorAlert:parsedJson]; 289 294 } 290 } else {291 [Keyword throwJsonErrorAlert:parsedJson];292 295 } 293 296 } … … 452 455 } 453 456 454 - (void)getValidKeywords {457 - (void)getValidKeywords:(BOOL)fromNetwork { 455 458 // successResult = { 456 459 // success: true, … … 465 468 // }; 466 469 467 Keyword *conn = [[[Keyword alloc] init] autorelease]; 468 [conn setTheDelegate:[VIPConnect sharedInstance]]; 469 [conn setActionSel:@selector(doNothing:)]; 470 [conn setConnectionUrl:[conn urlFromAction:@"getvalidkeywords"]]; 471 472 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:1] retain]; 473 [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domain"]; 474 475 [conn setPayload:requestData]; 476 NSDictionary *parsedJson = [conn performLookup:FALSE]; 477 [self fillValidKeywordsDict:parsedJson]; 478 [requestData release]; 470 if (fromNetwork) { 471 Keyword *conn = [[[Keyword alloc] init] autorelease]; 472 [conn setTheDelegate:[VIPConnect sharedInstance]]; 473 [conn setActionSel:@selector(doNothing:)]; 474 [conn setConnectionUrl:[conn urlFromAction:@"getvalidkeywords"]]; 475 476 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:1] retain]; 477 [requestData setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domain"]; 478 479 [conn setPayload:requestData]; 480 NSDictionary *parsedJson = [conn performLookup:FALSE]; 481 [self fillValidKeywordsDict:parsedJson]; 482 [requestData release]; 483 } else { 484 [self fillValidKeywordsDict:nil]; 485 } 479 486 } 480 487








