Xcode需要帮助合并GPS项目,Accelerometer项目,Compass项目和MySQL项目

时间:2013-01-14 11:58:29

标签: mysql xcode gps accelerometer compass-geolocation

我有4个Xcode项目(GPS,加速度计,指南针和MySQL)。

他们每个人都编写得很好并且工作正常。

我想将所有这些组合成一个项目,这样我就可以将GPS,Accelerometer和Compass信息发送到mySQL数据库。

我尝试将.h.m以及项目所需的框架复制到另一个。

主要是问题出现在这里:

- (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);
}

这是包含speedLabel的结构:

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

感谢您的帮助

2 个答案:

答案 0 :(得分:0)

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

#import "CoreLocationDemoViewController.h"

我无法在你的代码中看到任何瑕疵。

该代码是在@implementation@end范围内调用的吗?您是否将其声明为属性,然后@synthesize

答案 1 :(得分:0)

为了看到来自GPS接口的变量,我确实使用了下面的技术,我在堆栈溢出中找到了某个地方:

// 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上的一个按钮将相关数据存储到每个数据中?

非常感谢

Regisma