English 中文(简体)
目标 C - 错误:在预计浮动点值时使用的点值
原标题:iPhone Objective C - error: pointer value used where a floating point value was expected

我不理解为什么会发生这一错误。 相关守则:

照片。

#import <CoreData/CoreData.h>

@class Person;

@interface Photo :  NSManagedObject  
{
}

@property (nonatomic, retain) NSData * imageData;
@property (nonatomic, retain) NSNumber * Latitude;
@property (nonatomic, retain) NSString * ImageName;
@property (nonatomic, retain) NSString * ImagePath;
@property (nonatomic, retain) NSNumber * Longitude;
@property (nonatomic, retain) Person * PhotoToPerson;

@end

照片

#import "照片。"

#import "Person.h"

@implementation Photo 

@dynamic imageData;
@dynamic Latitude;
@dynamic ImageName;
@dynamic ImagePath;
@dynamic Longitude;
@dynamic PhotoToPerson;

@end

这是制作的一张地图“Controller.m”。 如果有的话,CLocationDegrees CLat和CLong线路:

                CLLocationDegrees CLLat = (CLLocationDegrees)photo.Latitude;    
                CLLocationDegrees CLLong = (CLLocationDegrees)photo.Longitude;

给我留下错误:在预计浮动点值时使用的点值。

for(int i = 0; i < iPerson; i++)
        {
            //get the person that corresponds to the row indexPath that is currently being rendered and set the text
            Person * person = (Person *)[myArrayPerson objectAtIndex:i];
            //get the photos associated with the person
            NSArray * PhotoArray =  [person.PersonToPhoto allObjects];
            int iPhoto = [PhotoArray count];

        for(int j = 0; j < iPhoto; j++)
        {
            //get the first photo (all people will have atleast 1 photo, else they will not exist). Set the image
            Photo * photo = (Photo *)[PhotoArray objectAtIndex:j];

            if(photo.Latitude != nil && photo.Longitude != nil)
            {
                MyAnnotation *ann = [[MyAnnotation alloc] init];
                ann.title = photo.ImageName;
                ann.subtitle = photo.ImageName;

                CLLocationCoordinate2D cord;                    
                CLLocationDegrees CLLat = (CLLocationDegrees)photo.Latitude;    
                CLLocationDegrees CLLong = (CLLocationDegrees)photo.Longitude;

                cord.latitude = CLLat;
                cord.longitude = CLLong;

                ann.coordinate = cord;
                [mkMapView addAnnotation:ann];              

            }       
        }   
    }
最佳回答

NSNumber并不是一种浮动类型,而是个点,因此,你需要这样做来转换:

CLLocationDegrees CLLat = (CLLocationDegrees)[photo.Latitude doubleValue];    
CLLocationDegrees CLLong = (CLLocationDegrees)[photo.Longitude doubleValue];
问题回答

暂无回答




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签