0

I want to put the function parameters into an array and I can not figure this out for the life of me. labelPoi is an object class that contains imageLocationX, imageLocationY, and name. I am trying to assign values found in one ViewController to values in another ViewController and it is not working for me.

This is in my First ViewController

PointOfInterest.imageLocationX = (((([self getDegreesFromRadians:angle_horizontal] / [self getDegreesFromRadians:FOV_Horizontal]))) *1024);
        PointOfInterest.imageLocationY = ((1-(([self getDegreesFromRadians:angle_to_bottom_of_view] / [self getDegreesFromRadians:FOV_Vertical])))*576);

PictureViewController *newlabel = [[PictureViewController alloc] display:PointOfInterest.imageLocationX andY:PointOfInterest.imageLocationY withName:PointOfInterest.name];

And this is in my second ViewController (PictureViewController)

- (id)display:(double)imageXX andY:(double)imageYY withName:(NSString *)namee{
NSLog(@"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
NSLog(@"imageX: %f",imageXX);
NSLog(@"imageY: %f", imageYY);
NSLog(@"name: %@", namee);

labelPoi.imageLocationX = imageXX;
labelPoi.imageLocationY = imageYY;
labelPoi.name = name;
[transfer addObject:labelPoi];
NSLog(@"label.x: %f should be: %f", labelPoi.imageLocationX, imageXX);
NSLog(@"label.y: %f should be: %f", labelPoi.imageLocationY, imageYY);
NSLog(@"label.name: %@ should be: %@",labelPoi.name,namee);

return self;

}

And this is the output:

2013-07-18 14:21:14.731 AR_UAV_App[10641:11303] %%%%%%%%%%%%%%%%%%%%%%%%
2013-07-18 14:21:14.731 AR_UAV_App[10641:11303] imageX: 224.485718
2013-07-18 14:21:14.731 AR_UAV_App[10641:11303] imageY: 116.353401
2013-07-18 14:21:14.731 AR_UAV_App[10641:11303] name: Beutel Student Health Center
2013-07-18 14:21:14.731 AR_UAV_App[10641:11303] label.x 0.000000
2013-07-18 14:21:14.731 AR_UAV_App[10641:11303] label.y 0.000000 should be 116.353401
2013-07-18 14:33:29.882 AR_UAV_App[10700:11303] label.name: (null) should be: Beutel Student Health Center#############################################################

Why does

NSLog(@"label.x: %f should be: %f", labelPoi.imageLocationX, imageXX);

output 0.00000?

EDIT: This is my Poi class which is labelPoi

#import "Poi.h"

@implementation Poi
@synthesize longitude;
@synthesize latitude;
@synthesize name;
@synthesize x;
@synthesize y;
@synthesize distance;
@synthesize isVisibleToCamera;

-(id)initWithLatitude:(double)lat AtLongitude:(double)lon withName:(NSString *)name{
    self = [super init];
    if(self){
        self.latitude = lat;
        self.longitude = lon;
        self.name = name;
    }
    return self;
}
2
  • 3
    Is labelPoi nil? You need to create the object first with alloc and init. Commented Jul 18, 2013 at 19:37
  • Why did you remove the code? This isn't answerable at all without some code. Commented Jul 19, 2013 at 20:41

1 Answer 1

6

You need to allocate and initialize labelPOI. It is nil, and trying to access a property on, or send a message to, nil does nothing.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.