2016-05-27 5 views
0

Objectはallocとinit..canの後にnilの記述を返します。いずれかの場合、サーバーから来るデータを表示する必要があります...編集ボタンをクリックすると、そのクラスのshoow部屋のクラス..内部のテキストフィールドには、いずれかの.can情報を表示するには、肝炎ここiOS:オブジェクトはallocとinitの後にnilの記述を返します

@interface HeadOfficeDetails : NSObject 

@property(nonatomic,strong) NSMutableArray *ofcContact; 

@property(nonatomic,strong) OfficeDocument *ofcDocument; 
@property(nonatomic,strong) OfficePrice *ofcPrice; 
@property(nonatomic,strong) CityClass *city; 
@property(nonatomic,strong) StateClass *state; 
@property(nonatomic,strong) DistrictClass *district; 

@property(nonatomic,strong)NSString *shrtname; 
@property(nonatomic,strong)NSString *shwrmname; 
@property(nonatomic,strong)NSString *shop; 
@property(nonatomic,strong)NSString *door; 
@property(nonatomic,strong)NSString *buildng; 
@property(nonatomic,strong)NSString *flr; 
@property(nonatomic,strong)NSString *tele; 
@property(nonatomic,strong)NSString *pin; 
@property(nonatomic,strong)NSString *main; 
@property(nonatomic,strong)NSString *dist; 
@property(nonatomic,strong)NSString *designan; 
@property(nonatomic,strong)NSString *depart; 
@property(nonatomic,strong)NSString *emai; 
@property(nonatomic,strong)NSString *mobile; 
@property(nonatomic,strong)NSString *strt; 
@property(nonatomic,strong)NSString *area; 


@property(nonatomic,strong) NSString *jwleryname; 
@property(nonatomic,strong) NSString *officeid; 


-(void)setAttributes:(NSDictionary *)attributes; 




/////////////////////////////////////////////// 
showroom class 



headdetails=[[HeadOfficeDetails alloc]init]; 


self.txtshowroom.text=headdetails.jwleryname; 
NSLog(@"%@ :",self.txtshowroom.text); 


NSNumber *officeid=headdetails.officeid; 
NSLog([NSString stringWithFormat:@"%@",officeid]); 

[self.txtshortname setText:headdetails.jwleryname]; 
[self.txtshowroom setText:headdetails.shwrmname]; 
[self.txtstreet setText:headdetails.strt]; 
[self.txtarea setText:headdetails.area]; 
[self.txtmain setText:headdetails.main]; 
[self.txtbuilding setText:headdetails.buildng]; 
[self.txtname setText:self.cntctcls.contactname]; 
[self.txtdesign setText:self.cntctcls.desig]; 
[self.txtdepartmnt setText:self.cntctcls.depart]; 
[self.txtmbl setText:self.cntctcls.mobile]; 
[self.txtemail setText:self.cntctcls.email]; 
[self.txtfloor setText:headdetails.flr]; 
[self.txttel setText:headdetails.tele]; 
[self.txtpincode setText:headdetails.pin]; 
[self.txtshop setText:headdetails.shop]; 

答えて

0

私を助けて、私は、データ中に保存NSObjectクラスのデータをサーバから取得し、他に表示ショーのためのコード例を配置していますそのインスタンスを使用して続き

はFBLoginのuserDetaulsを格納するためNSObjectクラスを作成することです:

#import <Foundation/Foundation.h> 

@interface FBUser : NSObject 

@property (nonatomic,strong) NSString *FBUserId; 
@property (nonatomic,strong) NSString *FBUserName; 
@property (nonatomic,strong) NSString *FBUserFirstName; 
@property (nonatomic,strong) NSString *FBUserLasttName; 
@property (nonatomic,strong) NSString *FBUserEmail; 
@property (nonatomic,strong) NSString *FBUserBio; 
@property (nonatomic,strong) NSString *FBUserLocation; 

+(instancetype)SharedFBUser; 
-(void)ClearFBuser; 
+(NSString*)CheckEmtryElseAlert:(NSString*)strValue; 

@end 

後は、ここでは、我々はそれが中にコードallocinitを行うようにする場合は不要nilを見つけた場合、一度FBUserオブジェクトをallcate SharedFBUserを作成する実装クラスであります時刻を表示

データに.Hクラスを保存するため FBUserクラスを使用する方法については、次のコード今
#import "FBUser.h" 


static FBUser* fbObject; 

@implementation FBUser 

+(instancetype)SharedFBUser 
{ 
    if(fbObject == nil) 
    { 
     fbObject =[[FBUser alloc]init]; 
    } 

    return fbObject; 
} 
-(void)ClearFBuser 
{ 

    fbObject = nil; 
    self.FBUserId = nil; 
    self.FBUserName = nil; 
    self.FBUserFirstName =nil; 
    self.FBUserLasttName = nil; 
    self.FBUserEmail = nil; 
    self.FBUserBio = nil; 
    self.FBUserLocation = nil; 

} 

#import <UIKit/UIKit.h> 
#import "FBUser.h" 
@interface LoginViewController : UIViewController 
@property(nonatomic,strong)FBUser *fbObject; 
@end 

そして、あなたはFBCallback内のデータを保存することができます:

[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, link, first_name, last_name, picture.type(large), email, birthday, bio ,location ,friends ,hometown , friendlists"}] 
    startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { 
     if (!error) 
     { 
      NSLog(@"resultis:%@",result); 
      [FBUser SharedFBUser].FBUserId =[result valueForKey:@"id"]; 
      [FBUser SharedFBUser].FBUserEmail =[result valueForKey:@"email"]; 
       [FBUser SharedFBUser].FBUserName =[result valueForKey:@"name"]; 
      [FBUser SharedFBUser].FBUserFirstName =[result valueForKey:@"first_name"]; 
      [FBUser SharedFBUser].FBUserLasttName =[result valueForKey:@"last_name"]; 
     } 
     else 
     { 
      NSLog(@"Error %@",error); 
     } 
    }]; 

そしてショーのために次のコードを使用については、この完全な説明を助けるFBuserクラスに格納したデータ

#import "FBUser.h" 
    self.lblEmail.text = [FBUser SharedFBUser].FBUserEmail; 
    self.lblusename.text = [FBUser SharedFBUser].FBUserName; 
    self.lblfirstname.text = [FBUser SharedFBUser].FBUserFirstName; 
    self.lbllastname.text = [FBUser SharedFBUser].FBUserLasttName; 

・ホープ作成します。これは私の作業コードです。

0

あなたは何をしているのか分かりません。最初にオブジェクトを解析するための構文解析辞書のようなものが必要でしょうか。

headdetails=[[HeadOfficeDetails alloc]init];

ので、すべてのプロパティがnil意志作成された新しいオブジェクト。

あなたはあなたがあなたの自己またはのようないくつかの第三のライブラリを探してそれを解析することができます

headdetails=[[HeadOfficeDetails alloc]initWithDictionary:attributes]; 

のようにそれに値を割り当てる必要がありますとき、これまでユーザーがクリック私は、テキストフィールド内のデータを表示したいと思いJSonModel

+0

編集ボタンと一度私はテキストフィールドの任意のものを更新wilの更新 –

+0

私はそこにnsobjectクラスを持っている私はキーの値を設定した –

+0

あなたはサーバーからデータを要求すると、あなたはJSONを返す戻ってくるだろう、その後、あなたのUIにマップすることができます。私はあなたがiOS開発の初心者です、初心者のための本の一部を最初に読ませてください。 RayWenderlicは良いチュートリアルをたくさん持っていました。あなたの問題を理解するためにhttps://www.raywenderlich.com/55384/ios-7-best-practices-part-1を読むことができます。 – Nick

関連する問題