0
我無法以任何方式引用此內容,並且無法運行。 我可以在任何其他類中運行void,只是創建一個函數並調用它,但在這個類中沒有視圖加載。所以Q是,我該如何運行它?從另一個類別啓動時運行無效
我試過引用其他類的變量,但它給編譯器錯誤。
getCoords的返回值必須是double類型的,因爲它是座標。
#import "OmarAnnotation.h"
#import <CommonCrypto/CommonHMAC.h>
#import <netdb.h>
#import "AppDelegate.h"
#import "MapViewController.h"
@implementation SFAnnotation
@synthesize image;
@synthesize latitude;
@synthesize longitude;
@synthesize string;
+(void) getCoords {
NSString *string = @"http://jerwuqu.info/iambored/?GETPOS";
NSURL *url = [NSURL URLWithString:string];
NSString *otherURLContents = [NSString stringWithContentsOfURL:url];
NSLog(otherURLContents);
NSArray* foo = [otherURLContents componentsSeparatedByString: @","];
NSString *longi = [foo objectAtIndex: 0];
NSString *lati = [foo objectAtIndex: 1];
NSLog(longi);
NSLog(lati);
double latiDouble = [lati doubleValue];
double longiDouble = [longi doubleValue];
}
- (CLLocationCoordinate2D)coordinate;
{
double extern *latiDouble;
double extern *longiDouble;
CLLocationCoordinate2D theCoordinate;
theCoordinate.latitude = latiDouble;
theCoordinate.longitude = longiDouble;
return theCoordinate;
}
- (void)dealloc
{
[image release];
[super dealloc];
}
- (NSString *)title
{
return @"Omar";
}
// optional
- (NSString *)subtitle
{
return @"Ortdenhegen";
}
@end
//這是我在其他類文件
- (void)viewDidLoad
{
self.mapView.mapType = MKMapTypeStandard; //Satelite?
self.mapAnnotations = [[NSMutableArray alloc] initWithCapacity:2];
SFAnnotation *sfAnnotation = [[SFAnnotation alloc] init];
[self.mapAnnotations insertObject:sfAnnotation atIndex:0];
[SFAnnotation getCoords]; // <- The line with an error
[self cityAction:self];
[self gotoLocation];
}
沒有工作:(得到lldb錯誤沒有任何e錯誤消息。 發佈viewDidLoad以上。 –
哦,我的壞...你應該使用'sfAnnotation'(你的變量,而不是類)。換句話說,'[sfAnnotation getCoords];'編輯原始帖子。 – Tom
感謝它工作:) –