0
我們試圖修改iphone文本字段中的數據,然後將(數據)返回到服務器中的mysql數據庫。如何以及在哪裏將ASIFormDataRequest合併到Xcode中?
我們有幾個問題:
是ASIFormDataRequest用於此的首選工具?如果不是,你能推薦一個並解釋如何合併? 如果ASIFormDataRequest是正確的工具,我們如何以及在哪裏將ASIFormDataRequest合併到Xcode和PHP中?
以下是包含我們編寫的代碼的三個文件,我們歡迎您提供所有的見解。感謝您的支持!
DetailViewController.h
#import <UIKit/UIKit.h>
@interface DetailViewController : UIViewController {
NSDictionary *newsArticle;
IBOutlet UILabel *titleLabel;
IBOutlet UILabel *timeLabel;
IBOutlet UITextField *fieldname;
IBOutlet UITextField *fieldtitle;
IBOutlet UITextField *fielddate;}
@property (nonatomic, copy) NSDictionary *newsArticle;
@end
DetailViewController.m
#import "DetailViewController.h"
@interface DetailViewController()
@end
@implementation DetailViewController
@synthesize newsArticle;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
titleLabel.text = [newsArticle objectForKey:@"name"];
timeLabel.text = [newsArticle objectForKey:@"title"];
fieldname.text = [newsArticle objectForKey:@"name"];
fieldtitle.text = [newsArticle objectForKey:@"title"];
fielddate.text = [newsArticle objectForKey:@"date"];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
php文件
$con = mysql_connect($DB_HostName,$DB_User,$DB_Pass) or die(mysql_error());
mysql_select_db($DB_Name,$con) or die(mysql_error());
$query = mysql_query("SELECT * FROM afitest");
$arr = array();
while($row = mysql_fetch_assoc($query)) {
$arr[] = $row;
}
echo json_encode($arr);
?>