Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSString *user = _username.text;
- NSString *password = _password.text;
- AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://thesite.com/login.php"]];
- [httpClient setParameterEncoding:AFFormURLParameterEncoding];
- NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST"
- path:@"http://thesite.com/login.php"
- parameters:@{@"username":user, @"password":password}];
- AFHTTPRequestOperation * httpOperation = [httpClient HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
- //success code
- } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
- //error handler
- }];
- [httpClient enqueueHTTPRequestOperation:httpOperation];
- [self performSegueWithIdentifier:@"secondVC"];
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- if ([[segue identifier] isEqualToString:@"secondVC"]) {
- SecondViewController *second = (SecondViewController *)[segue destinationViewController];
- second.userString = self.user;
- }
- }
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- [defaults setObject:username forKey:@"UserName"];
- [defaults synchronize];
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- NSString *username = [defaults objectForKey:@"UserName"];
- SecondViewController * sVC = [SecondViewController alloc] initWithUserName: username];
- @property (nonatomic, strong) NSString * userName
- - (id) initWithUserName: (NSString *) name
- {
- self = [super initWithNibName: @"SecondViewController"
- bundle: nil];
- if (self)
- {
- self.userName = name;
- }
- return self;
- }
- secondClass *appdelegate = [NSApp delegate];
- [appdelegate initwithDetails:userName withPassword:password];
- -(id)initwithDetails:(NSString *)user withPassword:(NSString *)password
- {
- userName = [NSString stringWithFormat:@"%@", user];
- newPass=[NSString stringWithFormat:@"%@", password];
- return self;
- }
- #import <Foundation/Foundation.h>
- @protocol ProcessDataDelegate <NSObject>
- @required
- - (void) processSuccessful: (BOOL)success;
- @end
- @interface ClassWithProtocol : NSObject
- {
- id <ProcessDataDelegate> delegate;
- }
- @property (retain) id delegate;
- -(void)startSomeProcess;
- @end
- #import "ClassWithProtocol.h"
- @implementation ClassWithProtocol
- @synthesize delegate;
- - (void)processComplete
- {
- [[self delegate] processSuccessful:YES];
- }
- -(void)startSomeProcess
- {
- [NSTimer scheduledTimerWithTimeInterval:5.0 target:self
- selector:@selector(processComplete) userInfo:nil repeats:YES];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement