为什么这个函数返回一个指针?

And*_*son 1 iphone cocoa-touch objective-c

当我调用这个函数时,它似乎返回一个指针而不是一个int.当我尝试NSLog返回值时,我收到一条警告"从不兼容的指针类型传递NSLog的参数1".如果NSLog运行,它会崩溃.

这与静态方法有关吗?我怎样才能找回真正的int?

我正在使用SDK 3.0

这是有问题的功能:

+(int) getZoomFromExtent: (CLLocationCoordinate2D)bottomLeft
            withTopRight:(CLLocationCoordinate2D)topRight
             withPixelsX:(int)pixelsX 
             withPixelsY:(int)pixelsY 
         withMapContents: (RMMapContents*) contents;
Run Code Online (Sandbox Code Playgroud)

这是.h代码:

#import <Foundation/Foundation.h>
#import <math.h>
#import <CoreLocation/CLLocation.h>
#import "RMTile.h"
#import "RMMapContents.h"

@interface AnnasMath : NSObject {}

+(CLLocationCoordinate2D) normalizePixelCoords:(CLLocationCoordinate2D) point;
+(RMTile)tileWithCoordinate:(CLLocationCoordinate2D)point andZoom:(int)zoom;
+(NSArray *)getTileArrayWithUpperLeft:(CLLocationCoordinate2D)upperLeft andLowerRight: (CLLocationCoordinate2D)lowerRight fromZoom:(int)bottomZoom toZoom:(int)topZoom;
+(int)getTileCountWithUpperLeft:(CLLocationCoordinate2D)upperLeft andLowerRight:(CLLocationCoordinate2D)lowerRight fromZoom:(int)bottomZoom toZoom:(int)topZoom;
+(int) getZoomFromExtent: (CLLocationCoordinate2D)bottomLeft 
             withTopRight:   (CLLocationCoordinate2D)topRight
              withPixelsX:(int)pixelsX
              withPixelsY:(int)pixelsY
          withMapContents: (RMMapContents*) contents;
Run Code Online (Sandbox Code Playgroud)

@结束

这是.m代码的开头:

#import "AnnasMath.h"
#import <Foundation/Foundation.h>
#import <math.h>
#import "TileWrapper.h"

@implementation AnnasMath

...
Run Code Online (Sandbox Code Playgroud)

我使用它如下:

int zoom = [AnnasMath getZoomFromExtent:[[extent objectForKey:@"bottomLeft"]coordinate] 
               withTopRight:[[extent objectForKey:@"topRight"]coordinate]
                            withPixelsX:300
                            withPixelsY:300 
                        withMapContents:t.mapVC.mapView.contents];

NSLog("About to set the zoom to %i", zoom);
Run Code Online (Sandbox Code Playgroud)

Chu*_*uck 10

请注意,它表示"参数1" - 而您正在查看的变量是参数2.您将传递一个C字符串作为NSLog的第一个参数而不是NSString(它写得像@"something"而不仅仅是"something").