我需要传递类PassengerNavi数据服务器Parse给授权用户。然后将数据写入NSString。如何从PFUser获取数据我不知道,我真的需要帮助开发人员)
我的ViewController.m文件:
#import <CloudKit/CloudKit.h>
#import <Parse/Parse.h>
#import "PassengerNavi.h"
#import "ViewController.h"
#import "RegistrationConsole.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (IBAction)authorizationController:(id)sender {
[PFUser logInWithUsernameInBackground:self.username.text
password:self.password.text block:^(PFUser *user, NSError *error)
{
if (!error) {
PassengerNavi *PassengerViewController = [[PassengerNavi alloc]initWithNibName:@"PassengerNavi" bundle:nil];
[self presentViewController:PassengerViewController animated:YES completion:nil];
} else {
UIAlertView *errorAlertView = [[UIAlertView alloc]initWithTitle:@"British Airways" message:@"Your have Business Class ticket. Please use First Class ticket or contact with British Airways customer center." delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil, nil];
[errorAlertView show];
}
}];
}
- (IBAction)registrationController:(id)sender {
RegistrationConsole *RegistrationViewController = [[RegistrationConsole alloc]initWithNibName:@"RegistrationConsole" bundle:nil];
[self presentViewController:RegistrationViewController animated:nil completion:nil];
}
@end
My PassengerNavi.m:
#import "ViewController.h"
#import <Parse/Parse.h>
@interface PassengerNavi ()
@end
@implementation PassengerNavi
- (void)viewDidLoad {
[super viewDidLoad];
[[[[UIApplication sharedApplication] delegate] window] rootViewController];
PFQuery *test = [PFQuery queryWithClassName:@"_User"];
[test whereKey:@"google" equalTo:[PFUser currentUser]];
[test whereKey:@"objectId" equalTo:[NSNumber numberWithInt:1]];
NSArray *arrayofObjectIds = [test findObjects];
PFQuery *query = [PFUser query];
[query whereKey:@"objectId" containedIn:arrayofObjectIds];
NSArray *followingArray = [query findObjects];
NSLog(@"%@",followingArray);
self.clubWorldID = followingArray;
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"ba_fc_wallpaper.jpg"]];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (IBAction)britishDialler:(id)sender {
BACalling *CallerViewController = [[BACalling alloc]initWithNibName:@"BACalling" bundle:nil];
[self presentViewController:CallerViewController animated:YES completion:NULL];
}
- (IBAction)britishMessenger:(id)sender {
BAMessenger *MessengerViewController = [[BAMessenger alloc]initWithNibName:@"BAMessenger" bundle:nil];
[self presentViewController:MessengerViewController animated:YES completion:nil];
}
- (IBAction)personalProfileView:(id)sender {
PersonalProfile *PersonalViewController = [[PersonalProfile alloc]initWithNibName:@"PersonalProfile" bundle:nil];
[self presentViewController:PersonalViewController animated:YES completion:nil];
}
- (IBAction)aboutSoftwareView:(id)sender {
AboutSoftware *AboutViewController = [[AboutSoftware alloc]initWithNibName:@"AboutSoftware" bundle:nil];
[self presentViewController:AboutViewController animated:YES completion:nil];
}
@end
答案 0 :(得分:0)
试试这段代码:
SecondViewController *vc = [[SecondViewController alloc] init];
vc.usernameObjectId = // <-- however you store/produce the value in FirstViewController
之后,按/显示/无论vc
。
仅供参考: 最好将NSString
属性声明为:
@property (copy, nonatomic) NSString *...