I have followed this tutorial:
http://www.shawngrimes.me/2011/04/custom-map-pins-for-mapkit/#comment-193
but I can't add a title and description
(see my code here http://pastebin.com/03mDLc9q)
You are trying to set name and description as properties of your annotation's view, you should be using title and subtitle on your annotation object - MyAnnotationClass, the annotation view will use title and subtitle of this object when the callout is rendered.
I changed your code to work here: http://pastebin.com/YRGYhQev
#interface MyAnnotationClass : NSObject<MKAnnotation>
#property (nonatomic, retain) NSString *title;
#property (nonatomic, retain) NSString *subtitle;
#property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
-(id) initWithCoordinate:(CLLocationCoordinate2D) coordinate;
#end
MyAnnotationClass.m
#import "MyAnnotationClass.h"
#implementation MyAnnotationClass
-(id) initWithCoordinate:(CLLocationCoordinate2D) coordinate{
self=[super init];
if(self){
_coordinate = coordinate;
}
return self;
}
-(void) dealloc{
[_title release];
[_subtitle release];
[super dealloc];
}
#end
ViewController.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#interface ViewController : UIViewController<MKMapViewDelegate> {
IBOutlet MKMapView *_myMapView;
NSArray *_myAnnotations;
}
#property (nonatomic, retain) NSArray *myAnnotations;
#property (nonatomic, retain) IBOutlet MKMapView *myMapView;
#end
ViewController.m
#import "ViewController.h"
#import "AppDelegate.h"
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#import "PlaceMark.h"
#import "MyAnnotationClass.h"
#interface ViewController ()
#end
#implementation ViewController
#synthesize myMapView = _myMapView;
#synthesize myAnnotations = _myAnnotations;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(void) viewDidLoad{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
//Initialize annotation
MyAnnotationClass *commuterLotAnnotation=[[MyAnnotationClass alloc] initWithCoordinate:CLLocationCoordinate2DMake(appDelegate.latitude , appDelegate.longitude)];
commuterLotAnnotation.title = #"Hello title";
commuterLotAnnotation.subtitle = #"Correct";
MyAnnotationClass *overflowLotAnnotation=[[MyAnnotationClass alloc] initWithCoordinate:CLLocationCoordinate2DMake(appDelegate.latitude , appDelegate.longitude)];
overflowLotAnnotation.title = #"Hello title";
overflowLotAnnotation.subtitle = #"Correct";
//Add them to array
self.myAnnotations=[NSArray arrayWithObjects:commuterLotAnnotation, overflowLotAnnotation, nil];
//Release the annotations now that they've been added to the array
[commuterLotAnnotation release];
[overflowLotAnnotation release];
//add array of annotations to map
[_myMapView addAnnotations:_myAnnotations];
}
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation{
static NSString *parkingAnnotationIdentifier=#"ParkingAnnotationIdentifier";
if([annotation isKindOfClass:[MyAnnotationClass class]]){
//Try to get an unused annotation, similar to uitableviewcells
MKAnnotationView *annotationView=[_myMapView dequeueReusableAnnotationViewWithIdentifier:parkingAnnotationIdentifier];
//If one isn't available, create a new one
if(!annotationView){
annotationView=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:parkingAnnotationIdentifier];
//Here's where the magic happens
annotationView.image=[UIImage imageNamed:#"apple.gif"];
annotationView.canShowCallout = YES;
}
return annotationView;
}
return nil;
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#end
I see that the tutorial has the MyAnnotationClass interface as:
#interface MyAnnotationClass : NSObject
When I used MKAnnotation I set my annotation interface up as:
#interface MyAnnotationClass : MKAnnotationView <MKAnnotation>
Then in the MyAnnotationClass.m file I have the following methods:
- (NSString *)title{
return self.name;
}
- (NSString *)subtitle{
return self.description;
}
Related
I am new in objective c.I have created a project which consist of a mapView
In ViewController.h in ny project,
#import <UIKit/UIKit.h>
#import "MapKit/MapKit.h"
#interface ViewController : UIViewController
#property (weak, nonatomic) IBOutlet MKMapView *mapView;
#end
In ViewController.m file i have viewDidLoad
- (void)viewDidLoad {
[super viewDidLoad];
mapView.showsUserLocation=YES;
// Do any additional setup after loading the view, typically from a nib.
}
I want to give coordinates of more then one location in my code, and I want to show loc.png icon on map corresponding to those coordinates. how can I accomplish this task? And how to zoom the map to maximum scale ?
Form this link you can download my sample project: https://drive.google.com/file/d/0B5pNDpbvZ8SnZGZnU1ZfbjZMRWs/view?usp=sharing
I had working on your question and this are my results, use this code, now Iam using a custom class that implements the MKAnnotation protocol
EDITED
Place.h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
#interface Place : NSObject<MKAnnotation>
#property (nonatomic) CLLocationCoordinate2D coordinate;
// Title and subtitle for use by selection UI.
#property (nonatomic, nullable) NSString *title;
#property (nonatomic, nullable) NSString *subtitle;
-(id)initWithCoordinates:(CLLocationCoordinate2D) coordinates andName:(NSString*)name;
#end
Place.m
#import "Place.h"
#implementation Place
#synthesize coordinate,title,subtitle;
-(id)initWithCoordinates:(CLLocationCoordinate2D) coordinates andName:(NSString*)name
{
self = [super init];
if(self)
{
[self setTitle:name];
[self setCoordinate:coordinates];
}
return self;
}
#end
Modified Code
#import "ViewController.h"
#import "Place.h"
#interface ViewController () <MKMapViewDelegate>
#property NSMutableArray * arrayOfLocations;
#end
#implementation ViewController
#synthesize mapView;
- (void)viewDidLoad {
[super viewDidLoad];
mapView.showsUserLocation=YES;
self.arrayOfLocations = [NSMutableArray arrayWithObjects:[[Place alloc] initWithCoordinates:CLLocationCoordinate2DMake(40.416691, -3.700345) andName:#"MADRID"],
[[Place alloc] initWithCoordinates:CLLocationCoordinate2DMake(35.416691, -3.700345) andName:#"SOMEWARE IN THE MAP"],
[[Place alloc] initWithCoordinates:CLLocationCoordinate2DMake(35.416691, -40.700345) andName:#"SOMEWARE IN THE MAP1"],
[[Place alloc] initWithCoordinates:CLLocationCoordinate2DMake(20.416691, -50.700345) andName:#"SOMEWARE IN THE MAP2"], nil];
[self.mapView setDelegate:self];
[self.mapView addAnnotations:self.arrayOfLocations];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (nullable MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView * annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:#"testAnnotationView"];
if(annotationView == nil){
annotationView = [[MKAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:#"testAnnotationView"];
annotationView.image = [UIImage imageNamed:#"loc.png"];
annotationView.canShowCallout = true;
}
return annotationView;
}
#end
Hope this helps you,
This is how it looks
I would like to store coordinates with additional data according to the gps locations and view the coordinates in a map with pin annotations and the additional data in Callouts (Title, Subtitle). Ive already managed to get my data from my device to my iPhone via Bluetooth. I get about every second new coordinates but my device is very slow, so i only need so save the coordinates and the additional data every 10 meters. Im new in iOS programming and Im looking forward to your help! ;)
Here is my Code:
ViewController.m
#interface SecondViewController ()
#end
extern float lat;
extern float lon;
#implementation SecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self setupGradients];
_mapView.showsUserLocation = YES;
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if (lat > 0) {
double pointOneLatitude = lat;
double pointOneLongitude = lon;
CLLocationCoordinate2D pointOneCoordinate = {pointOneLatitude, pointOneLongitude};
KTMapAnnotation *pointOneAnnotation = [[KTMapAnnotation alloc] initWithCoordinate:pointOneCoordinate];
[pointOneAnnotation setTypeOfAnnotation:PIN_ANNOTATION];
[self.mapView addAnnotation:pointOneAnnotation];
}
}
ViewController.h
import <UIKit/UIKit.h>
import <MapKit/MapKit.h>
import "KTMapAnnotation.h"
#interface SecondViewController : UIViewController
#property (weak, nonatomic) IBOutlet MKMapView *mapView;
KTMapAnnotation.h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
#interface KTMapAnnotation : NSObject <MKAnnotation> {
CLLocationCoordinate2D _coordinate;
}
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate;
// 08 - Add a Callout
- (NSString*) title;
- (NSString*) subtitle;
#property(nonatomic, strong) NSString *typeOfAnnotation;
#end
KTMapAnnotation.m
#import "SecondViewController.h"
#import "KTMapAnnotation.h"
#implementation KTMapAnnotation
#synthesize coordinate=_coordinate;
#synthesize typeOfAnnotation;
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate
{
self = [super init];
if (self != nil)
{
_coordinate = coordinate;
}
return self;
}
- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate
{
_coordinate = newCoordinate;
}
// Add a Callout
- (NSString*) title
{
return #"Title“;
}
// Add a Callout
- (NSString*) subtitle
{
return #„subtitel";
}
#end
I've searched all over google, and stack overflow for a solution, but I wasn't able to find an answer that solved my problem. Sorry for the long post, as I'm trying to give as much information as I can. I'm new to iOS and Objective- c, but not programming in general due to being asked to switch over from Android by my company, so any help is appreciated.
I'm trying to assign a value to an NSString in one class from a TextField in another, but I get the error:
**-[ViewController name:]: unrecognized selector sent to instance 0x78712fe0**
when I run the app in the simulator.
Relevant code:
//UserInfo.h
#import <Foundation/Foundation.h>
#interface UserInfo : NSObject <NSCoding>
#property (nonatomic, strong) NSString *name;
#property (nonatomic, strong) NSString *age;
#property (nonatomic, strong) NSString *address;
#end
//UserInfo.m
#import "UserInfo.h"
static NSString *nameKey = #"userName";
static NSString *ageKey = #"userAge";
static NSString *addressKey = #"userAddress";
static NSString *userInfoKey = #"userInfoKey";
#implementation UserInfo
#synthesize name;
#synthesize age;
#synthesize address;
- (id) initWithCoder:(NSCoder *)coder
{
self = [super init];
self.name = [coder decodeObjectForKey:nameKey];
self.age = [coder decodeObjectForKey:ageKey];
self.address = [coder decodeObjectForKey:addressKey];
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeObject:self.name forKey:nameKey];
[coder encodeObject:self.age forKey:ageKey];
[coder encodeObject:self.address forKey:addressKey];
}
#end
//ViewController.h
#import <UIKit/UIKit.h>
#import "UserInfo.h"
#interface ViewController : UIViewController <UITextFieldDelegate, UITextViewDelegate, NSCoding>
#property (nonatomic, strong) UserInfo *userInfoObject;
#property (nonatomic, weak) IBOutlet UILabel *titleLabel;
#property (nonatomic, weak) IBOutlet UILabel *nameLabel;
#property (nonatomic, weak) IBOutlet UILabel *ageLabel;
#property (nonatomic, weak) IBOutlet UILabel *addressLabel;
#property (nonatomic, weak) IBOutlet UITextField *nameText;
#property (nonatomic, weak) IBOutlet UITextField *ageText;
#property (nonatomic, weak) IBOutlet UITextField *addressText;
#property (nonatomic, weak) IBOutlet UIButton *saveBtn;
- (IBAction)saveBtnTouched:(id)sender;
- (void) saveUserInfo;
- (void) loadUserInfo;
- (void) setUserInterfaceValues;
- (IBAction)nameText:(id)sender;
- (IBAction)ageText:(id)sender;
- (IBAction)addressText:(id)sender;
#end
//ViewController.m
#import "ViewController.h"
#import "UserInfo.h"
#interface ViewController ()
#end
#implementation ViewController
#synthesize titleLabel;
#synthesize nameLabel;
#synthesize ageLabel;
#synthesize addressLabel;
#synthesize nameText;
#synthesize ageText;
#synthesize addressText;
#synthesize saveBtn;
static NSString *userInfoKey = #"userInfoKey";
- (void)viewDidLoad {
[super viewDidLoad];
[self loadUserInfo];
if(!self.userInfoObject)
{
self.userInfoObject = [[UserInfo alloc] init];
}
[self setUserInterfaceValues];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
self.saveBtn.enabled = YES;
return YES;
}
- (BOOL)textFieldShouldReturn:(UITextField*)textField
{
return YES;
}
- (BOOL) textFieldShouldEndEditing:(UITextField *)textField
{
[self.nameText resignFirstResponder];
[self.ageText resignFirstResponder];
[self.addressText resignFirstResponder];
return YES;
}
- (IBAction)saveBtnTouched:(id)sender
{
NSLog(#"%# was entered into the name field", self.nameText.text);
NSLog(#"%# was entered into the age field", self.ageText.text);
NSLog(#"%# was entered into the address field", self.addressText.text);
[self textFieldShouldEndEditing:self.nameText];
[self textFieldShouldEndEditing:self.ageText];
[self textFieldShouldEndEditing:self.addressText];
self.userInfoObject.name = self.nameText.text;
self.userInfoObject.age = self.ageText.text;
self.userInfoObject.address = self.addressText.text;
[self saveUserInfo];
self.saveBtn.enabled = NO;
}
- (void)saveUserInfo
{
NSData *userInfoData = [NSKeyedArchiver archivedDataWithRootObject:self.userInfoObject];
[[NSUserDefaults standardUserDefaults] setObject:userInfoData forKey:userInfoKey];
}
- (void)loadUserInfo
{
NSData *userInfoData = [[NSUserDefaults standardUserDefaults] objectForKey:userInfoKey];
if(userInfoData)
{
self.userInfoObject = [NSKeyedUnarchiver unarchiveObjectWithData:userInfoData];
}
}
- (void) setUserInterfaceValues
{
self.nameText.text = self.userInfoObject.name;
self.ageText.text = self.userInfoObject.age;
self.addressText.text = self.userInfoObject.address;
}
- (IBAction)nameText:(id)sender {
}
- (IBAction)ageText:(id)sender {
}
- (IBAction)addressText:(id)sender {
}
#end
//AppDelegate.h
#import <UIKit/UIKit.h>
#import "ViewController.h"
#import "UserInfo.h"
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#property (strong, nonatomic) ViewController *viewController;
#end
//AppDelegate.m
#import "AppDelegate.h"
#import "ViewController.h"
#import "UserInfo.h"
#interface AppDelegate ()
#end
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
//all the other generated methods. Taken out due to space.
#end
Three breakpoints are set that are supposidly the source of the problem:
From the ViewController.m, in - (void)setUserInterfaceValues
self.nameText.text = self.userInfoObject.name;
(I assume that this applies to the other two lines below it also)
Also from the ViewController.m, in - (void)viewDidLoad
[self setUserInterfaceValues];
And finally from the AppDelegate.m, in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
self.window.rootViewController = self.viewController;
From what I understand, and have learned from searching this issue, the app is trying to send data to something that doesn't exist, the NSString name being the culprit. Others have suggested to make sure that my .xib file is connected to the ViewController, and I have verified that it is.
As another bit of information, I'm not using a storyboard for this app, and instead am using the interface builder. I'm aware that there are advantages to storyboards, and I would like to be using them, but my company uses the interface builder and does a lot of things programmatically, so I'm learning to develop without.
[EDIT]: Issue solved thanks to Ian.
I have a UITableView that opens a view with a map, i called Mapa class. I am having problems passing any kind of text information from this table view to the map. I need to send a string text to be the title of my map, and the coordinates of a CLLocation.
Here is part of the code
MyTableView.m:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
instMapa = [[Mapa alloc] initWithNibName:#"Mapa" bundle:nil];
instMapa.mytext = #"pass text to be the title";
[self.navigationController pushViewController:instMapa animated:YES];
}
Mapa.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <MapKit/MKAnnotation.h>
#class MapViewAnnotation;
#interface Mapa : UIViewController <MKMapViewDelegate> {
IBOutlet MKMapView *mapView;
NSString *stringTitle;
NSString *mytext;
MapViewAnnotation *newAnnotation;
}
#property (nonatomic, retain) IBOutlet MKMapView *mapView;
#property (nonatomic, retain) NSString *stringTitle;
#property (nonatomic, retain) NSString *mytext;
#property (nonatomic, retain) MapViewAnnotation *newAnnotation;
#end
Mapa.m
#import "Mapa.h"
#import "MapViewAnnotation.h"
#implementation Mapa
#synthesize mapView;
#synthesize stringTitle;
#synthesize mytext;
#synthesize newAnnotation;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
CLLocationCoordinate2D location;
location.latitude = (double) 51.501468;
location.longitude = (double) -0.141596;
// Add the annotation to our map view
newAnnotation = [[MapViewAnnotation alloc] initWithTitle:mytext andCoordinate:location];
[self.mapView addAnnotation:newAnnotation];
}
// When a map annotation point is added, zoom to it (1500 range)
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{
MKAnnotationView *annotationView = [views objectAtIndex:0];
id <MKAnnotation> mp = [annotationView annotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 1500, 1500);
[mv setRegion:region animated:YES];
[mv selectAnnotation:mp animated:YES];
}
// Received memory warning
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
// If the view unloads, release the map view
- (void)viewDidUnload {
}
- (void)dealloc {
[newAnnotation release];
[mytext release];
[stringTitle release];
[mapView release];
[super dealloc];
}
#end
MapViewAnnotation.h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
#interface MapViewAnnotation : NSObject <MKAnnotation> {
NSString *title;
CLLocationCoordinate2D coordinate;
}
#property (nonatomic, copy) NSString *title;
#property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d;
#end
MapViewAnnotation.m
#implementation MapViewAnnotation
#synthesize title, coordinate;
- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d {
[super init];
title = ttl;
coordinate = c2d;
return self;
}
- (void)dealloc {
[title release];
[super dealloc];
}
#end
Thanks for the help!
From your question, I understand that; you need to pass the string value of the selected table view cell to your map view.
For that you need to write this code in your didSelectRowAtIndexPath,
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
instMapa.mytext = cell.textLabel.text;
I've boiled a very complex set of web services and searches down to the simple following code.
I need to be able to add annotations to a map in response to a search (or in the sample below to the click of a button), then allow the user to click the button again and get a new set of results. In reality there will be a different number, but in the simplified example, we always add one annotation to the mapview.
I believe my code should remove the existing annotations and add a new one, but it leaks 32 bytes on second and subsequent button pushes.
What am I missing ? (Or retaining as the case may be!)
testViewController.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import "MyMark.h"
#interface testViewController : UIViewController {
MKMapView *mapView;
}
#end
testViewController.m
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
self.title=#"test";
}
return self;
}
- (void) storeLocationInfo: (CLLocationCoordinate2D) loc title:(NSString *)t subtitle:(NSString *)st index:(int)i {
NSArray * annotations = [mapView annotations];
[mapView removeAnnotations:annotations];
MyMark * mymark=[[MyMark alloc] initWithCoordinate:loc];
[mapView addAnnotation:mymark];
[MyMark release];
}
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:#"Add point to map" style:UIBarButtonItemStylePlain target:self action:#selector(addPushed)];
[self.navigationItem setRightBarButtonItem:barButton];
[barButton release];
mapView=[[MKMapView alloc] initWithFrame:CGRectMake(0.0,0.0,self.view.frame.size.width,self.view.frame.size.height)];
mapView.showsUserLocation=FALSE;
mapView.delegate=self;
[self.view insertSubview:mapView atIndex:0];
[mapView release];
}
- (void) addPushed {
MKCoordinateRegion reg = mapView.region;
[self storeLocationInfo:reg.center title:#"price" subtitle:#"title" index:1];
}
- (void)dealloc {
[super dealloc];
}
MyMark.h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
#interface MyMark : NSObject<MKAnnotation> {
CLLocationCoordinate2D coordinate;
NSString * title;
NSString * subtitle;
int index;
}
#property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
#property (nonatomic, readonly) int index;
#property (nonatomic, retain) NSString * title;
#property (nonatomic, retain) NSString * subtitle;
-(id)initWithCoordinate:(CLLocationCoordinate2D) coordinate;
-(id)setCoordinate:(CLLocationCoordinate2D) coordinate;
-(id)setTitle:(NSString *)t subtitle:(NSString *)st index:(int)i ;
#end
MyMark.m
#import "MyMark.h"
#implementation MyMark
#synthesize coordinate, index;
#synthesize title,subtitle;
-(id)initWithCoordinate:(CLLocationCoordinate2D) c{
coordinate=c;
NSLog(#"%f,%f",c.latitude,c.longitude);
return self;
}
-(id)setCoordinate:(CLLocationCoordinate2D) c{
coordinate=c;
NSLog(#"%f,%f",c.latitude,c.longitude);
return self;
}
-(id)setTitle:(NSString *)t subtitle:(NSString *)st index:(int) i{
self.title=t;
self.subtitle=st;
index=i;
return self;
}
-(void) dealloc {
[title release];
[subtitle release];
[super dealloc];
}
You're not releasing mymark in storeLocationInfo:title:subtitle:index:. It looks like the problem is a typing error. The line that reads
[MyMark release];
should be
[mymark release];
Note the case difference. The first line sends release to the class, not the instance.