#import <Foundation/Foundation.h> #import "iLenexaMapView.h" #import "ArcGIS.h" @interface iLenexaModel : NSObject { iLenexaMapView *lenMapView; AGSTiledMapServiceLayer *basemap; AGSTiledMapServiceLayer *crimemap; AGSTiledMapServiceLayer *parksmap; AGSTiledMapServiceLayer *aerials; AGSGraphicsLayer *serviceRequests; AGSPoint *currLocation; NSString *lyrName; NSString *lyrURL; NSString *lyrType; NSString *basemapName; } @property (nonatomic,retain) iLenexaMapView *lenMapView; @property (nonatomic, retain) AGSTiledMapServiceLayer *basemap; @property (nonatomic, retain) AGSTiledMapServiceLayer *crimemap; @property (nonatomic, retain) AGSTiledMapServiceLayer *parksmap; @property (nonatomic, retain) AGSTiledMapServiceLayer *aerials; @property (nonatomic, retain) AGSPoint *currLocation; @property (nonatomic, retain) AGSGraphicsLayer *serviceRequests; @property (nonatomic, retain) NSString *basemapName; @property (nonatomic, retain) NSString *lyrName; @property (nonatomic, retain) NSString *lyrURL; @property (nonatomic, retain) NSString *lyrType; //note the plus sign in from of this method. We are going to need to call this from wherever we //want to collect the property from + (id)sharedModel; @end
#import "iLenexaModel.h" static iLenexaModel *sharedMyModel = nil; @implementation iLenexaModel @synthesize lenMapView, crimemap, basemap,parksmap,serviceRequests, aerials; @synthesize lyrType, lyrName, lyrURL, currLocation; @synthesize basemapName; +(id)sharedModel{ @synchronized(self){ if (sharedMyModel==nil) { [[self alloc] init]; } } return sharedMyModel; } + (id)allocWithZone:(NSZone *)zone{ @synchronized(self){ if (sharedMyModel == nil) { sharedMyModel = [super allocWithZone:zone]; return sharedMyModel; } } return nil; } -(id)copyWithZone:(NSZone *)zone{ return self; } -(id)retain{ return self; } -(unsigned)retainCount{ return UINT_MAX; } -(void)release{} -(id)autorelease{ return self; } -(id)init{ if (self=[super init]) { NSLog(@Jeremy's rad singleton); } } -(void)dealloc { [lenMapView release]; [super dealloc]; } @end
iLenexaModel *myModel = [iLenexaModel sharedModel]; myModel.lenMapView = self;
iLenexaModel *myModel = [iLenexaModel sharedModel]; mapViewer.myBasemap = myBasemap; [mapViewer changeBasemap]; [self.navigationController pushViewController:mapViewer animated:YES]; if ([lyrType isEqualToString:@Tiled]) { [mapViewer addLenexaTiledMapLayer:lyrURL :myModel.lyrName]; } else if([lyrType isEqualToString:@Dynamic]){ [mapViewer addLenexaDynamicMapLayer:lyrURL :myModel.lyrName]; } else if([lyrType isEqualToString:@Graphic]){ [mapViewer addLenexaGraphicsMapLayer:lyrURL :myModel.lyrName]; } else{ NSLog(@Something is wrong here!!!!); } mapViewer.lyrName = myModel.lyrName; //and so on... }
if([lyrName isEqualToString:@Economic Development]){ NSLog(@Economic Development); iLenexaTableSubView *subTable = [[iLenexaTableSubView alloc] initWithNibName:@iLenexaTableSubView bundle:[NSBundle mainBundle]]; NSString *path3 = [[NSBundle mainBundle] pathForResource:@econDevelopment ofType:@plist]; NSMutableArray* myarr2 = [[NSMutableArray alloc] initWithContentsOfFile:path3]; subTable.myVarArray = myarr2; subTable.mapViewer = mapViewer; subTable.myBasemap = myModel.basemap; [myarr2 release]; [self.navigationController pushViewController:subTable animated:YES]; [subTable release]; }
- (void) collectCrimeData;
-(void) collectCrimeData{ NSLog(@We collect the crime data!!!); }
- (IBAction) addNewServiceRequest:(id) sender;
-(IBAction)addNewServiceRequest:(id)sender{ //record the currPoint in here iLenexaModel *myModel = [iLenexaModel sharedModel]; myModel.currLocation = myModel.lenMapView.mapView.gps.currentPoint; iLenexaServiceRequestDetail *srRequest = [[iLenexaServiceRequestDetail alloc] initWithNibName:@iLenexaServiceRequestDetail bundle:[NSBundle mainBundle]]; [self.tabbarcontroller presentModalViewController:srRequest animated:YES]; [srRequest release]; }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //collect the string from the indexPath before you set the current viewcontroller NSString *selectDay = [NSString stringWithFormat:@%d, indexPath.row]; //instantiate a new variable that is typed SecondView, set the textLabel property on it. SecondView *myView = [self.tabBarController.viewControllers objectAtIndex:1]; [myView.myLabel setText:selectDay]; //now set the selectedViewController to the SecondView instance we just made self.tabBarController.selectedViewController = myView; }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.