Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > Mobile > Mobile Forum > iOS - Error แบบนี้เกิดจากอะไรค่ะ ช่วยดูให้หน่อยค่ะขอบคุณคร้าาา


[Mobile] iOS - Error แบบนี้เกิดจากอะไรค่ะ ช่วยดูให้หน่อยค่ะขอบคุณคร้าาา

 
Topic : 103464

Guest



เกิดจากอะไรค่ะ

error แบบนี้ต้องแก้ยังไงค่ะ



Tag : Mobile, MySQL, iOS, iPhone, Objective-C, Mac

Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-12-10 17:54:38 By : fern_105 View : 1019 Reply : 6
 

 

No. 1



โพสกระทู้ ( 74,059 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ในบทความผมก็ทำแบบ Step by Step แล้วน่ะครับ ทำไมยังมี Error อีก
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-10 18:52:08 By : mr.win
 

 

No. 2

Guest


เพราะใช้ xcode 5 หรือป่าวไม่แน่ใจ แล้วมันจะแก้ตรงไหน
Viewlogin.h
Code (Objective-C)
01.#import <UIKit/UIKit.h>
02. 
03.@interface Viewlogin : UIViewController{
04.    IBOutlet UITextField*txtID;
05.    IBOutlet UITextField*txtPassword;
06.    NSMutableData*inputlogin;
07.    UIAlertView*loging;
08.     
09. 
10.     
11.}
12. 
13. 
14.@property (nonatomic,strong)IBOutlet UITextField *txtID;
15.@property (nonatomic,strong) IBOutlet UITextField *txtPassword;
16.@property(nonatomic,strong)NSMutableData *inputlogin;
17.@property(nonatomic,strong)UIAlertView*loging;
18.@property(nonatomic,strong)UIButton*btnClose;
19.@property(nonatomic,strong)UIButton*btnLogin;
20. 
21.- (IBAction)btnLogin:(id)sender;
22.- (IBAction)btnClose:(id)sender;

Viewlogin.m
Code (Objective-C)
001.#import "Viewlogin.h"
002.#import "loginViewController.h"
003. 
004. 
005.@implementation Viewlogin
006.@synthesize txtID;
007.@synthesize txtPassword;
008.@synthesize inputlogin;
009.@synthesize btnLogin;
010.@synthesize loging;
011. 
012. 
013. 
014.- (void)viewDidLoad
015.{
016.    [super viewDidLoad];
017.    // Do any additional setup after loading the view, typically from a nib.
018.}
019.- (IBAction)clearInputText:(id)sender {
020.    txtID.text = @"";
021.    txtPassword.text = @"";
022.}
023. 
024.- (IBAction)btnLogin:(UIBarButtonItem *)sender {
025.     
026.    // Show Progress Loading...
027.     
028.    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
029.     
030.    loging
031.    = [[UIAlertView alloc] initWithTitle:@"" message:@"Login Checking..." delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
032.    UIActivityIndicatorView *progress= [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125, 50, 30, 30)];
033.    progress.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
034.    [loging addSubview:progress];
035.    [progress startAnimating];
036.    [progress release];
037.    [loging show];
038.     
039.     
040.    //sUsername&sPassword
041.    NSString *post = [NSString stringWithFormat:@"sID=%@&sPassword=%@",[txtID text],[txtPassword text]];
042.     
043.    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
044.    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
045.     
046.     
047.    NSURL *url = [NSURL URLWithString:@"http://localhost:8888/checkLogin.php"];
048.     
049.    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
050.                                                           cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
051.                                                       timeoutInterval:10.0];
052.    [request setHTTPMethod:@"POST"];
053.    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
054.    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
055.    [request setHTTPBody:postData];
056.     
057.    NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
058.     
059.     
060.     
061.    if (theConnection) {
062.        self.inputlogin = [[NSMutableData data] retain];
063.    } else {
064.        UIAlertView *connectFailMessage = [[UIAlertView alloc] initWithTitle:@"NSURLConnection " message:@"Failed in viewDidLoad"  delegate: self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
065.        [connectFailMessage show];
066.        [connectFailMessage release];
067.    }
068.     
069.}
070. 
071.- (IBAction)btnClose:(id)sender {
072.}
073. 
074.//- (IBAction)btnClose:(id)sender {
075.//}
076. 
077.- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
078.{
079.    [inputlogin setLength:0];
080.}
081. 
082.- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
083.{
084.    sleep(3);
085.    [inputlogin appendData:data];
086.}
087. 
088.- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
089.{
090.     
091.    // ปิด Progress
092.    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
093.    [loging dismissWithClickedButtonIndex:0 animated:YES];
094.     
095.    [connection release];
096.    [inputlogin release];
097.     
098.    // inform the user
099.    UIAlertView *didFailWithErrorMessage = [[UIAlertView alloc] initWithTitle: @"เกิดข้อผิดพลาด " message: @"ไม่สามารถเชื่อมต่อกับเซิร์ฟเวอร์ได้"  delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
100.    [didFailWithErrorMessage show];
101.    [didFailWithErrorMessage release];
102.     
103.     
104.    //inform the user
105.    NSLog(@"Connection failed! Error - %@", [error localizedDescription]);
106.     
107.}
108. 
109. 
110.- (void)connectionDidFinishLoading:(NSURLConnection *)connection
111.{
112.    // ปิด Progress
113.    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
114.    [loging dismissWithClickedButtonIndex:0 animated:YES];
115.     
116.     
117.    // Return Status E.g : { "Status":"1", "MemberID":"1", "Message":"Login Successfully" }
118.    // 0 = Error
119.    // 1 = Completed
120.     
121.    if(inputlogin)
122.    {
123.         
124.        id jsonObjects = [NSJSONSerialization JSONObjectWithData:inputlogin options:NSJSONReadingMutableContainers error:nil];
125.         
126.        // value in key name
127.        NSString *strStatus = [jsonObjects objectForKey:@"Status"];
128.        NSString *strID = [jsonObjects objectForKey:@"ID"];
129.        NSString *strMessage = [jsonObjects objectForKey:@"Message"];
130.        NSString *strName = [jsonObjects objectForKey:@"FNameE"];
131.        NSLog(@"Status = %@",strStatus);
132.        NSLog(@"ID = %@",strID);
133.        NSLog(@"postID = %@",txtID.text);
134.        NSLog(@"Message = %@",strMessage);
135.        NSLog(@"Name = %@",strName);
136.         
137.        //ดึงID,PasswordจากUserDefaults
138.         
139.        NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
140.         
141.        // saving an NSString
142.        [prefs setObject:txtID.text forKey:@"ID"];
143.        [prefs setObject:txtPassword.text forKey:@"password"];
144.         
145.        [prefs synchronize];
146.         
147.         
148.        // Login Completed
149.        if( [strStatus isEqualToString:@"1"] ){
150.             
151.            [self performSegueWithIdentifier:@"LoginSuccess" sender:self];
152.             
153.             
154.        }
155.         
156.         
157.        else // Login Failed
158.        {
159.            UIAlertView *error =[[UIAlertView alloc]
160.                                 initWithTitle:@"เกิดข้อผิดพลาด"
161.                                 message:strMessage delegate:self
162.                                 cancelButtonTitle:@"OK" otherButtonTitles: nil];
163.            [error show];
164.        }
165.         
166.         
167.    }
168.     
169.    // release the connection, and the data object
170.    [connection release];
171.    [inputlogin release];
172.     
173.}
174. 
175. 
176.- (void)didReceiveMemoryWarning
177.{
178.    [super didReceiveMemoryWarning];
179.    // Dispose of any resources that can be recreated.
180.}
181. 
182.- (void)dealloc {
183.    [txtID release];
184.    [txtPassword release];
185.    [super dealloc];
186.}
187. 
188.//- (IBAction)btnLogin:(id)sender {
189.//}
190. 
191.@end

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-10 19:32:20 By : fern_105
 

 

No. 3



โพสกระทู้ ( 1,579 )
บทความ ( 3 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


ได้กำหนด File's Owner และ Inspector ในส่วนของ Outlet หรือเปล่าครับ
เพราะบทความพี่วิวส่วนมากจะ copy โค้ดไปดื้อๆไม่ได้นะครับ เราต้องกำหนด Outlet ก่อนอ่ะครับ
อันนี้ผมเดาเอานะ เพื่อลืมกันครับเพราะเจอหลายเคสที่ copy ไปวางแล้ว Run สคริปเลย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-12 23:04:07 By : somparn
 

 

No. 4



โพสกระทู้ ( 54 )
บทความ ( 0 )



สถานะออฟไลน์


เชคตัว sdk ของ simulator ดูครับว่ามันใช่ sdk เดียวกันหรือป่าว ถ้าไม่ใช่ลองเปิด preference แล้ว update ดู
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-12 23:34:59 By : j4kkapongz
 

 

No. 5



โพสกระทู้ ( 43 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ลองเช็คในส่วนของ outlet ให้ดีๆครับ

หลังๆผม เอาแค่
{
IBOutlet UITextField *txtN;
}
แค่นี้พอครับ



@property (strong,nonatomic) UITextField *txtN; อันนี้ผมไม่ค่อยใช้ละ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-13 13:57:00 By : kwampien
 

 

No. 6

Guest


ขอบคุณผู้รู้ทุกท่านมากค่ะ ตอนนี้ login ผ่านแล้วค่ะ ขอบคุณค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-18 17:58:02 By : fern105
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : iOS - Error แบบนี้เกิดจากอะไรค่ะ ช่วยดูให้หน่อยค่ะขอบคุณคร้าาา
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่