Guest User

Untitled

a guest
Feb 8th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. NSMutableArray *profilesArr = [[[NSMutableArray alloc] initWithContentsOfFile:path]autorelease];
  2. NSMutableDictionary *tempDict = [[[NSMutableDictionary alloc] initWithDictionary:[profilesArr objectAtIndex:0]]autorelease];
  3.  
  4. NSString *dynamicURL = [tempDict objectForKey:@"dynamicLayer"];
  5. NSString *user = [tempDict objectForKey:@"user"];
  6. NSString *pass = [tempDict objectForKey:@"pass"];
  7. NSString *backgroundURL = [tempDict objectForKey:@"backgroundLayer"];
  8. NSMutableArray *tempVisible = [tempDict objectForKey:@"visibleLegend"];
  9.  
  10. [self.mapView removeMapLayerWithName:@"Tiled Layer"];
  11. [self.mapView removeMapLayerWithName:@"Dynamic Layer"];
  12. [self.mapView removeMapLayerWithName:@"Graphics Layer"];
  13. [self.mapView removeMapLayerWithName:@"Graphics Layer 2"];
  14. [self.mapView removeMapLayerWithName:@"Sketch Layer"];
  15. [self.mapView removeMapLayerWithName:@"Sketch Layer2"];
  16.  
  17. NSLog(@"load temp %@", tempVisible);
  18.  
  19.  
  20. self.visibleLegend = tempVisible;
  21. self.dynamicLayer.layerDefinitions = visibleLegend;
  22.  
  23. cred = [[AGSCredential alloc] initWithUser:user password:pass];
  24.  
  25. tiledLayer = [[AGSTiledMapServiceLayer alloc] initWithURL:[NSURL URLWithString:backgroundURL]];
  26.  
  27. self.backgroundLayerView =[self.mapView addMapLayer:tiledLayer withName:@"Tiled Layer"];
  28.  
  29. self.dynamicLayer = [[[AGSDynamicMapServiceLayer alloc] initWithURL:[NSURL URLWithString: dynamicURL] credential:cred]autorelease];
  30.  
  31. self.dynamicLayerView =[self.mapView addMapLayer:self.dynamicLayer withName:@"Dynamic Layer"];
  32.  
  33. [self loadMap];
  34.  
  35. NSString *pName = profileName;
  36. [self dismissModalViewControllerAnimated:YES];
  37.  
  38. NSMutableArray *profilesArr = [[NSMutableArray alloc] initWithContentsOfFile:path];
  39. NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] init ] ;
  40. NSMutableArray *tempArr = [[[NSMutableArray alloc] initWithArray:[tempDict objectForKey:@"visibleLegend"]]autorelease];
  41.  
  42. NSMutableArray *tester = [[[NSMutableArray alloc] initWithArray:self.visibleLegend] autorelease];
  43.  
  44. NSString *dynamicURL = [self.dynamicLayer.URL absoluteString];
  45. NSString *tiledURL = [self.tiledLayer.URL absoluteString];
  46. AGSCredential *currentCred= self.dynamicLayer.credential;
  47. NSString *user = currentCred.username;
  48. NSString *pass = currentCred.password;
  49.  
  50. tester = self.visibleLegend;
  51. [tempDict setObject:pName forKey:@"profileName"];
  52. [tempDict setObject:user forKey:@"user"];
  53. [tempDict setObject:pass forKey:@"pass"];
  54. [tempDict setObject:dynamicURL forKey:@"dynamicLayer"];
  55. [tempDict setObject:tiledURL forKey:@"backgroundLayer"];
  56. [tempDict setObject:tester forKey:@"visibleLegend"];
  57. NSLog(@"legend %@", self.visibleLegend);
  58. NSLog(@"tester %@", tester);
  59.  
  60. [profilesArr addObject:tempDict];
  61. if ([profilesArr containsObject:tempDict])
  62. NSLog(@"added");
  63. if ([profilesArr writeToFile:path atomically:NO])
  64. NSLog(@"new saved");
Add Comment
Please, Sign In to add comment