2014-04-21 47 views
0

我的應用程序出現問題。目前,我試圖將數據壓入我的PHP腳本。但是,當我按下按鈕時,整個App凍結。這是我的代碼。不兼容的指針使用'UITextField *'類型的表達式初始化'NSString *'類型

GuestlistViewControler.m文件

// 
// GuestlistViewControler.m 
// Club La Boom 
// 
// Created by Kevin Archambault on 2014-04-21. 
// Copyright (c) 2014 Club La Boom. All rights reserved. 
// 

#import "GuestlistViewControler.h" 

@implementation GuestlistViewControler 

-(IBAction)addData:(id)sender{ 

    NSString *name = self.NameText; 
    NSString *invite = self.InviteText; 
    NSString *email = self.EmailText; 
    NSString *phone = self.CellText; 
    NSString *date = self.DateText; 

    NSString *rawStr = [NSString stringWithFormat:@"name=%@&invite=%@&&email=%@&phone=%@&date=%@", name, 
         invite, 
         email, 
         phone, 
         date]; 

    NSData *data = [rawStr dataUsingEncoding:NSUTF8StringEncoding]; 

    NSURL *url = [NSURL URLWithString:@"http://www.clublaboom.com/guestlist_iphone.php"]; 
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; 

    [request setHTTPMethod:@"POST"]; 
    [request setHTTPBody:data]; 
    NSURLResponse *response; 
    NSError *err; 
    NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err]; 

    NSString *responseString = [NSString stringWithUTF8String:[responseData bytes]]; 
    NSLog(@"%@", responseString); 

    NSString *success = @"success"; 
    [success dataUsingEncoding:NSUTF8StringEncoding]; 

    NSLog(@"%lu", (unsigned long)responseString.length); 
    NSLog(@"%lu", (unsigned long)success.length); 



    [self dismissViewControllerAnimated:YES completion:nil]; // Dismiss the viewController upon success 

} 

@end 

GuestlistViewControler.h文件

// 
// GuestlistViewControler.h 
// Club La Boom 
// 
// Created by Kevin Archambault on 2014-04-21. 
// Copyright (c) 2014 Club La Boom. All rights reserved. 
// 

#import <Foundation/Foundation.h> 
#import <UIKit/UIKit.h> 
#import <CoreGraphics/CoreGraphics.h> 


@interface GuestlistViewControler : 
UITableViewController { 
    UITextField *_NameText; 
    UITextField *_InviteText; 
    UITextField *_EmailText; 
    UITextField *_CellText; 
    UITextField *_DateText; 
    UIButton *_SubmitButton; 
} 
@property (strong, nonatomic) IBOutlet UITableViewController *GuestlistViewControler; 

@property (nonatomic, retain) IBOutlet UITextField * NameText; 
@property (nonatomic, retain) IBOutlet UITextField * InviteText; 
@property (nonatomic, retain) IBOutlet UITextField * EmailText; 
@property (nonatomic, retain) IBOutlet UITextField * CellText; 
@property (nonatomic, retain) IBOutlet UITextField * DateText; 
@property (nonatomic, retain) IBOutlet UIButton * SubmitButton; 

@end 

感謝您的幫助

+3

錯誤消息對我來說很清楚的財產的.text。它是說你正在使用'UITextField *'在哪裏期待'NSString *'類型 –

回答

1

變化:

NSString *name = self.NameText; 
NSString *invite = self.InviteText; 
NSString *email = self.EmailText; 
NSString *phone = self.CellText; 
NSString *date = self.DateText; 

到:

NSString *name = self.NameText.text; 
NSString *invite = self.InviteText.text; 
NSString *email = self.EmailText.text; 
NSString *phone = self.CellText.text; 
NSString *date = self.DateText.text; 
+0

現在,你知道是否有方法來更改Date.DickText.text的Date鍵選擇器點擊UITextField? – KevLaBoomQc

+0

@ user3558397您可以在故事板中更改它 –

+0

我找不到確切位置..... – KevLaBoomQc

0

您需要訪問您的UITextField性能

NSString *name = self.NameText.text; 
NSString *invite = self.InviteText.text; 
NSString *email = self.EmailText.text; 
NSString *phone = self.CellText.text; 
NSString *date = self.DateText.text; 
相關問題