0

I have 4 Xcode projects ( GPS, Accelerometer, Compass and MySQL).

Each of them individually are compiling fine and are working fine.

I will like to combine all of them into one project so I can send the GPS, Accelerometer and Compass info to a mySQL database.

I have tried to copy the .h and the .m and the frameworks required from project to another.

Mainly the problem arises here :

- (IBAction)insert:(id)sender
{
    // create string contains url address for php file, the file name is phpFile.php, it receives parameter :name
    //NSString *strURL = [NSString stringWithFormat:@"http://localhost/phpFile.php?name=%@",txtName.text];
    NSString *strURL = [NSString stringWithFormat:@"http://localhost/phpFile.php?name=%@",speedLabel.text]; ************<   use of undefined identifier 'speedLabel'****

    // to execute php code
    NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];

    // to receive the returend value
    NSString *strResult = [[[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding]autorelease];

    NSLog(@"%@", strResult);
}

Here is the structure which speedLabel is contained :

@interface CoreLocationDemoViewController : UIViewController <CoreLocationControllerDelegate> {
    CoreLocationController *CLController;
    IBOutlet UILabel *speedLabel;
    IBOutlet UILabel *latitudeLabel;
    IBOutlet UILabel *longitudeLabel;
    IBOutlet UILabel *altitudeLabel;
    IBOutlet UILabel *timeLabel;
}

Thanks for your help

laxonline
  • 2,657
  • 1
  • 20
  • 37
user1961175
  • 19
  • 1
  • 4
  • Whats the problem? Or do you want us to copy all the MySQL code for you? – MCKapur Jan 14 '13 at 12:20
  • Hi,No The probelm that I have is I cannot access the speedLabel variable under : NSString *strURL = [NSString stringWithFormat:@"http://localhost/phpFile.php?speedLabel=%@",speedLabel.text]; When I try in my code I have an error which say use of undefined identifier speedLabel. Thanks Regisma – user1961175 Jan 14 '13 at 14:35

2 Answers2

0

Are you importing your .h file:

#import "CoreLocationDemoViewController.h"

I cannot see any flaws in your code whatsoever otherwise.

Is that code called inside the @implementation and @end scope? Are you declaring it as a property and do you then @synthesize it

MCKapur
  • 9,127
  • 9
  • 58
  • 101
  • Hi, the interface for the mySQL is under ConnectToDBAppDelegate.h and the statement NSString *strURL = [NSString stringWithFormat:@"http://localhost/phpFile.php?name=%@",speedLabel.text]; is under ConnectToDBAppDelegate.m The GPS info are under CoreLocationDemoViewController.h and the @synthesize for speedLabel is under CoreLocationDemoViewController.m. Under ConnectToDBAppDelegate.m I did import CoreLocationDemoViewController.h Thanks Regis – user1961175 Jan 14 '13 at 17:04
0

In order to see the variable which come from the GPS Interface I did used the technique below that I did found somewhere in stackoverflow :

// Globals.h
#ifndef Globals_h
#define Globals_h

extern NSInteger globalVariable;

#endif

// main.m 

NSInteger globalVariable;

int main(int argc, char *argv[])
{
   globalVariable = <# initial value #>;
    ...
}

// Prefix.pch

#ifdef __OBJC__
    #import 
    #import <Foundation/Foundation.h>
    #import "Globals.h"
#endif

And I did used the technique :

NSString *strURL = [NSString stringWithFormat:@"http://localhost/phpFile.php?name=%@",speedLabel.text];

to send the info to mysql database.

But I still need a bit of help.

I have one interface for the GPS, another one for the accelerometer, another one for the compass. How can I invoke each of them so I can store the related data to each of them by clicking on one button on the Iphone ?

Many thanks

Regisma

user1961175
  • 19
  • 1
  • 4
  • Hi, it seems that the trick does not work if I want to access the data from another interface such as the accelerometer. Can you guide me please? thanks Regis – user1961175 Jan 17 '13 at 23:19