Postado 13 de outubro de 201015 anos comment_158305 Oi de novo Galera. Seguinte, tô aqui tentando resolver um outro problema em um app que tô fazendo pra iPhone, mas anda dando pau a 3x4. O problema da vez é: eu tenho que coletar os dados de uma UITableView para exibir em um MKMapView, mas somente quando se seleciona uma opção ele exibe a anotação no mapa. Eu tentei até alocar a classe mapa dentro da classe da tabela, mas ele me dá esse erro: "Object Cannot be set - either readonly property or no setter foundation". Ai embaixo vai o código: // Esse é o código de implementação da tabela. #import "ComoChegar.h" @implementation ComoChegar @synthesize places; @synthesize texto; #pragma mark - #pragma mark View lifecycle - (void)viewDidLoad { [super viewDidLoad]; NSString *path = [[NSBundle mainBundle]pathForResource:@"lugares" ofType:@"plist"]; places = [NSMutableArray arrayWithContentsOfFile:path]; [places retain]; // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; } . . . #pragma mark - #pragma mark Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [places count]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell... lugar = [places objectAtIndex:indexPath.row]; cell.textLabel.text = [lugar objectForKey:@"Local"]; return cell; } . . . #pragma mark - #pragma mark Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Navigation logic may go here. Create and push another view controller. Mapa *detailViewController = [[Mapa alloc] initWithNibName:@"Mapa" bundle:nil]; detailViewController.locais = places; detailViewController.mapaZI = mapa; detailViewController.ZILeblon = ZIL; // O erro é exibido aqui. detailViewController.ZICentro = ZIC; // O erro é exibido também aqui. lugar = [places objectAtIndex:indexPath.row]; if ([lugar objectForKey:@"Local"] == @"Centro") { [mapa addAnnotation:ZIC]; } else if ([lugar objectForKey:@"Local"] == @"Leblon") { [mapa addAnnotation:ZIL]; } // Pass the selected object to the new view controller. [self.navigationController pushViewController:detailViewController animated:YES]; [detailViewController release]; } . . . - (void)dealloc { [super dealloc]; } @end // E esse o código do mapa #import "Mapa.h" @implementation Mapa @synthesize mapaZI; @synthesize places; @synthesize locais; -(MKAnnotationView *)mapview:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation { if ([annotation isKindOfClass:[MKUserLocation class]]) { return nil; } MKAnnotationView* anView = [theMapView dequeueReusableAnnotationViewWithIdentifier:@"MeuTipo"]; if (anView = nil) { anView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MeuTipo"]autorelease]; anView.image = [UIImage imageNamed:@"apple_touch_icon.png"]; } else { anView.annotation = annotation; } return anView; } . . . // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; // Definindo a anotação da ZI do centro no mapa... ZICentro = [[MKPointAnnotation alloc] init]; ZICentro.coordinate = CLLocationCoordinate2DMake(-43.181371, -22.901634); ZICentro.title = @"ZONAInternet Centro"; ZICentro.subtitle = @"Av. Pres. Vargas, 590, "; ZICentro.subtitle = @"sala 802, Centro-RJ."; // Definindo a anotação da ZI do Leblon no mapa... ZILeblon = [[MKPointAnnotation alloc] init]; ZILeblon.coordinate = CLLocationCoordinate2DMake(-22.983024, -43.224528); ZILeblon.title = @"ZONAInternet Leblon"; ZILeblon.subtitle = @"Rua General Urquiza, 163, "; ZILeblon.subtitle = @"Apto. 202, Leblon-RJ."; /* NSString *path= [[NSBundle mainBundle]pathForResource:@"lugares" ofType:@"plist"]; locais = [NSMutableArray arrayWithContentsOfFile:path]; [locais retain]; if ([places objectForKey:@"Local"] == @"Centro") { [mapaZI addAnnotation:ZICentro]; } else if ([places objectForKey:@"Local"] == @"Leblon") { [mapaZI addAnnotation:ZILeblon]; } */ } . . . - (void)dealloc { [super dealloc]; [ZICentro release]; [ZILeblon release]; } @end Alguém pode me ajudar? só falta isso para completar o aplicativo e não estou conseguindo sair do lugar... Denunciar
Postado 13 de outubro de 201015 anos Autor comment_158335 Tranquilo galera, dei jeito. Eu esquecí de colocar a property pro ZILeblon e pro ZICentro. Denunciar
Participe do debate
Você pode postar agora e se registrar depois. Se você tem uma conta, entre agora para postar com ela.