2013-01-14 38 views
0

我有4個Xcode項目(GPS,加速計,指南針和MySQL)。Xcode需要幫助合併GPS項目,加速度計項目,指南針項目和MySQL項目

他們每個人都單獨編譯好,工作正常。

我想將它們全部合併到一個項目中,以便我可以將GPS,加速度計和指南針信息發送到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; 
} 

感謝您的幫助

+0

請告訴我這個問題?或者你想讓我們爲你複製所有的MySQL代碼? – MCKapur

+0

嗨,沒有我有的問題是我無法訪問speedLabel變量:NSString * strURL = [NSString stringWithFormat:@「http://localhost/phpFile.php?speedLabel =%@」,speedLabel.text];當我嘗試在我的代碼中,我有一個錯誤,說使用未定義的標識speedLabel。謝謝Regisma – user1961175

回答

0

你輸入你的.h文件中:

#import "CoreLocationDemoViewController.h" 

否則,我無法在代碼中看到任何缺陷。

該代碼是否在@implementation@end範圍內調用?你宣佈它作爲一個屬性,你再@synthesize

+0

嗨,mySQL的接口在ConnectToDBAppDelegate.h和聲明NSString * strURL = [NSString stringWithFormat:@「http://localhost/phpFile.php?name =%@」,speedLabel.text];在ConnectToDBAppDelegate.m下GPS信息在CoreLocationDemoViewController.h下,speedLabel的@synthesize在CoreLocationDemoViewController.m下。在ConnectToDBAppDelegate.m下我沒有導入CoreLocationDemoViewController.h感謝Regis – user1961175

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

+0

嗨,似乎這個竅門不起作用,如果我想從其他接口,如加速度計訪問數據。你能指導我嗎?謝謝瑞吉斯 – user1961175