ios - cookie passing between viewcontrols -


I have developed iphone app's my questions. I have created php - mysql script and then I created the login screen on xcode. I send the http request and I read the cookies. But I want to control some other ideas. So I need to save phpsessid cookie and send http request with cookies. My question is how do I?

First view (login screen) .m file

  #import "Second viewHolt" // If you want to get all cookies: NSArray * all = [NSHTTPCookie Cookieswith Response Headerfield: [Feedback All Headfield] forURL: [NSURL URLWithString: @ "http://www.iosapp.com"]]; NSLog (@ "how many cookies:% d", all.count); // Store cookies: // NSHTTK Cookie storage is a singleton. [[NSHTTPCookieStorage Share HTTP Cookie Stost] Set Cookies: URL for All: [NSL URL URL String: @ "http://www.iosapp.com/"] Main document ur: zero]; // Now we can print all cookies: for (NSHQPKKY * cookie in all) {SECOND VUUUTURlUm * MVUCentroler = [[SecondViewControl ALLOC] IntuitCookie: cookie]; NSLog (@ "name:% @: value:% @, expiration:% @", cookie.Name, cookie .value, cookie.exe datedate); }   

second visual.h

  @ interface second view controller: UIViewController {NSHTTPCookie * _cookie; // ivar announcement} - (id) initWithCookie: (NSHTTPCookie *) Cookie function: // function prototype   

second viewpoint.m

  @implementation SecondViewControl - (id) initWithCookie: (NSHTTPCookie *) Cookie {_cookie = cookie; Self return; }   

second view.m button

  - (IBAction) homeb: (ID) sender {NSLog (@ "name:% @: value:% @, End:% @ ", _cookie.name, _cookie.value, _cookie.expiresDate); }   

And the blank cookie is not working: / NSLog

  2014-04-26 04: 35: 22.186 Login [73801: 60b] Name: PHPSESSID: Value: 49c1ed0c570dd85a3f7593c7e039086d, Termination: (Faucet) 2014-04-26 04: 35: 22.186 Login [73801: 60b] Login SUCCESS 2014-04-26 04: 35: 29.091 Login [73801: 60b] Name: (faucet): Price: (faucet), Termination: (faucet) (clicked seconviewcontrol button.)  

For your first question: "How do I cross the next scene"? / P>

Assume this is you viewController.h

  @interface view controller: UIViewController {NSHTTPCookie * _cookie; // ivar declaration} - (id) initWithCookie: (NSHTTPCookie *) Cookie; // function prototype @end   

viewController .m in

  @implementation viewController - (ID) initWithCookie: (NSHTTPCookie *) cookie {_cookie = cookie; Self return; } ... ... ... @end   

Login to you

  viewController * myViewController = [viewController alloc] initWithCookie: cookies];   

Or you can just create a setter inside your scene. Controller

  @ interface view controller: UIViewController {NSHTTPCookie * _cookie; // ivar declaration} - (zero) setCookie: (NSHTTPCookie *) cookie; // function prototype ... @end   

viewController .m in

  @implementation viewController - (zero) set cookie: (NSHTpc Cookies *) Cookie {_cookie = Cookie; } ... ... ... @end   

Login to you

  viewController * myViewController = [viewController alloc] init]; // or init with Xib name and whatever is // and then [myViewController setCookie: cookie]; // Here you have just crossed the cookie in your view. In the controller ivar   

H

  @ interface view controller: UIViewController {NSMutableArray * _cookiesArray; } - (zero) addCookieCookie: (NSHTTPCookie *) cookie; // function prototype @end   

viewController .m in

  @implementation viewController - (zero) AddCookieCookie: (NSHTTPCookie *) cookie {if (CookiesArray ) // When you are running for the first time, you should enter the array like this {cookiesArray = [[NSMutableArray alloc] init]; } [CookiesAreAdd Object: Cookies]; } ... ... ...   

Now you can have an array inside your second view controller @end

about your second question: Please explain a different question, show yourself and us the code.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -