Ios 目标C:CoreData和MapKit
我在coredata中有经度和纬度类型Double。叫艾德曼。我为singleton创建类usersIndexIos 目标C:CoreData和MapKit,ios,objective-c,core-data,mapkit,Ios,Objective C,Core Data,Mapkit,我在coredata中有经度和纬度类型Double。叫艾德曼。我为singleton创建类usersIndex .h #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> #import "AddMan.h" //OutgoingUser @interface usersIndex : NSObject //@property (nonatomic) AddMan* user; @property (
.h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
#import "AddMan.h"
//OutgoingUser
@interface usersIndex : NSObject
//@property (nonatomic) AddMan* user;
@property (nonatomic, retain) NSNumber *longtitude;
@property (nonatomic, retain) NSNumber *latitude;
+ (usersIndex *)sharedManager;
+ (void) del;
@end
我创建了ViewController和钩住的MapKit。在我的课堂上,我需要显示coredata中的所有标记。我如何实现这一点?
我有一个版本的如何做到这一点,但我不太明白它
for (int i = 0; i <_users.count; i ++) {
_index = i;
CustomMKPointAnnotation * myAnnot = [[CustomMKPointAnnotation alloc] init];
NSManagedObject * obj = [_users objectAtIndex: _index];
theCoordinate.latitude = [[obj valueForKey: @ "lantitude"] doubleValue];
theCoordinate.longitude = [[obj valueForKey: @ "longitude"] doubleValue];
myAnnot.coordinate = theCoordinate;
myAnnot.indexAnnotation = i;
myAnnot.title = [NSString stringWithFormat: @ "% @", [obj valueForKey: @ "name"]];
myAnnot.subtitle = [NSString stringWithFormat: @ "% @", [obj valueForKey: @ "lastname"]];
[Self.totalMapView addAnnotation: myAnnot];
}
for(int i=0;i
for (int i = 0; i <_users.count; i ++) {
_index = i;
CustomMKPointAnnotation * myAnnot = [[CustomMKPointAnnotation alloc] init];
NSManagedObject * obj = [_users objectAtIndex: _index];
theCoordinate.latitude = [[obj valueForKey: @ "lantitude"] doubleValue];
theCoordinate.longitude = [[obj valueForKey: @ "longitude"] doubleValue];
myAnnot.coordinate = theCoordinate;
myAnnot.indexAnnotation = i;
myAnnot.title = [NSString stringWithFormat: @ "% @", [obj valueForKey: @ "name"]];
myAnnot.subtitle = [NSString stringWithFormat: @ "% @", [obj valueForKey: @ "lastname"]];
[Self.totalMapView addAnnotation: myAnnot];
}