自己做了一个模拟用户登录界面,在登录时结构体中的变量乱码,很是头疼。
求大神。。
有如下类LoginViewController.m、serviceClass.m
LoginViewController.m有个按钮、点击时触发 serviceClass.m
LoginViewController.m中打印显示乱码。
serviceClass *a =[[serviceClass alloc] init];
[a loginService];
NSLog(@"user_id = %s",a.stLoginData.user_id);
NSLog(@"password = %s",a.stLoginData.password);
serviceClass.m打印正常
_stLoginData.user_id=(char *)sqlite3_column_text(statement, 0);
_stLoginData.password =(char *)sqlite3_column_text(statement, 1);
NSLog(@"loginData.user_id = [%s]",_stLoginData.user_id);
NSLog(@"loginData.password = [%s]",_stLoginData.password);
serviceClass.h
#import
typedef struct {
char *user_id ;
char *password;
} NSloginData;
@interface serviceClass : NSObject
@property(assign,nonatomic)NSloginData stLoginData;
-(void)loginService;
@end
======打印结果======
2016-09-22 13:21:26.293 lianjieWithCode[24739:2556153] loginData.user_id = [aa]
2016-09-22 13:21:26.294 lianjieWithCode[24739:2556153] loginData.password = [11]
2016-09-22 13:21:26.294 lianjieWithCode[24739:2556153] user_id = Ä*}
2016-09-22 13:21:26.294 lianjieWithCode[24739:2556153] password =