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

4

2 回答 2

0

您是否正在导入 .h 文件:

#import "CoreLocationDemoViewController.h"

否则,我看不出您的代码中有任何缺陷。

该代码是否在@implementationand@end范围内调用?您是否将其声明为财产,然后@synthesize呢?

于 2013-01-14T14:58:44.530 回答
0

为了查看来自 GPS 接口的变量,我确实使用了我在 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

我确实使用了这项技术:

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

将信息发送到 mysql 数据库。

但我仍然需要一点帮助。

我有一个用于 GPS 的接口,另一个用于加速度计,另一个用于指南针。如何调用它们中的每一个,以便通过单击 Iphone 上的一个按钮将相关数据存储到它们中?

非常感谢

注册表

于 2013-01-17T15:03:41.797 回答