There should be a registration page with Full Name, User Name, Password, Email and Register Button.
When we Click on Register Button we then go to Login Page where it validate the username and password that we created in registration page using NSUserDefaults.
Now if we give right credentials then it should redirect to logout page and when we next time open the app it should directly redirect to logout page.
Data Should be stored locally using NSUserDefaults(value should be stored in string format).
Login view controller .h
#import <UIKit/UIKit.h>
#interface ViewController2 : UIViewController
#property(strong, nonatomic)NSString *dataString;
#property(strong, nonatomic)NSString *dataString2;
#property (strong, nonatomic) IBOutlet UILabel *lblOutput;
#property (strong, nonatomic) IBOutlet UITextField *inputTxt1;
#property (strong, nonatomic) IBOutlet UITextField *inputTxt2;
- (IBAction)btnAction:(id)sender;
#end
Login view controller .m
#import "ViewController2.h"
#interface ViewController2 ()
#end
#implementation ViewController2
- (void)viewDidLoad {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *firstName = [defaults objectForKey:#"firstName"];
NSString *lastName = [defaults objectForKey:#"lastname"];
firstName = _inputTxt1.text;
lastName = _inputTxt2.text;
[super viewDidLoad];
NSLog(#"%#",self.dataString);
NSLog(#"%#",self.dataString2);
self.navigationItem.title = #"Login Page";
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)btnAction:(id)sender {
NSString *firstName = [_inputTxt1 text];
NSString *lastName = [_inputTxt2 text];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:firstName forKey:#"firstName"];
[defaults setObject:lastName forKey:#"lastname"];
[defaults synchronize];
// [Defaults setObject:#"Eezy"forKey:#"iOS"];
NSLog(#"%#",[defaults stringForKey:#"firstName"]);
NSLog(#"%#",[defaults stringForKey:#"lastName"]);
if ([self.dataString isEqualToString:[defaults objectForKey:#"firstName"]] && [self.dataString2 isEqualToString:[defaults objectForKey:#"lastName"]])
{
NSLog(#"goog");
[self performSegueWithIdentifier:#"segueToNextPage2" sender:self];
}
else
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Hey Listen" message:#"Wrong User Name or Password" delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
}
}
#end
The problem is that I have passed the value from registration page but when I am storing it in NSUserDefault then it is storing the value of username but in case of password it is showing null value.
FOR Saving login values you can use
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// saving an NSString
[prefs setObject:txtUsername.text forKey:#"userName"];
[prefs setObject:txtPassword.text forKey:#"password"];
[prefs synchronize];
FOR RETRIEVING Values
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// getting an NSString
NSString *savedUsername = [prefs stringForKey:#"userName"];
NSString *savedPassword = [prefs stringForKey:#"password"];
For logout:
[[NSUserDefaults standardUserDefaults] removeObjectForKey:#"Your Key"];
Here is the Solution i got :-
Step 1: In login page define a bool variable and set its value as true on clicking the login button
- (IBAction)btnAction:(id)sender {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setBool:YES forKey:#"registered"];
[prefs synchronize];
}
Step 2. Create a storyBoard in identity inspector as "UITabBarController". Keep in mind this will be the page where you want to go.
Step 3. In AppDelegate.h file just below #implemention write following code :-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if ([[NSUserDefaults standardUserDefaults] boolForKey:#"registered"]) {
UITabBarController *controller = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:#"UITabBarController"];
self.window.rootViewController = controller;
}
return YES;
}
That's it very simple.
Save the details in NSUserDefaults from registration page. Also make entry in NSUserDefaults to check whether user logged in or not.
[[NSUserDefaults standardUserDefaults]setValue:#"YES" forKey:#"isLoggedIn"];
In your AppDelegate's didFinishLaunching method, change the initialViewController based on isLoggedIn key value e.g.
if ([[[NSUserDefaults standardUserDefaults]valueForKey:#"isLoggedIn"] isEqualToString:#"YES"])
{
// redirect to logout screen
}
else
{
//show login or register screen
}
Related
I am saving Textfield text using NSUserDefaults on button click in ViewController2
My code is
ButtonClick()
{
NSUserDefaults *userDefaults =[NSUserDefaults standardUserDefaults];
[userDefaults setObject:keyWordField.text forKey:#"Keywords"];
[userDefaults synchronize];
}
Then ViewDidLoad method i am Retrieving like this
-(void)viewDidLoad
{
NSUserDefaults *userDefaults =[NSUserDefaults standardUserDefaults];
[keyWordArray addObject:[userDefaults objectForKey:#"Keywords"]];
[userDefaults synchronize];
}
Here i am assigning this keyWordArray to tableview
like cell.textlabel.text =[keyWordArray objectAtIndex:indexPath.row];
First i entered text(First) in textfield and click button it is showing in table like
First
Second time i entered text (second) in textfield and click button it is showing table like
First
Second
Here everything working fine. The problem is when i come to viewController2 from ViewController1. It is showing last entered value only
like
Second
what going wrong here?
Try This
- (IBAction)buttonclick:(id)sender {
[keyWordArray addObject:keyWordField.text];
NSUserDefaults *userDefaults =[NSUserDefaults standardUserDefaults];
[userDefaults setObject:keyWordArray forKey:#"Keywords"];
[userDefaults synchronize];
[selt.tableView reload]; //reload the table every time a new text is added
}
-(void)viewDidLoad {
if([[NSUserDefaults standardUserDefaults] objectForKey:#"Keywords"]==nil){
keyWordArray = [[NSMutableArray alloc] init];
}
else{
keyWordArray = [[NSUserDefaults standardUserDefaults] objectForKey:#"Keywords"];
}
}
Try this,
- (IBAction)buttonclick:(id)sender {
[keyWordArray addObject:keyWordField.text];
NSUserDefaults *userDefaults =[NSUserDefaults standardUserDefaults];
[userDefaults setObject:keyWordArray forKey:#"Keywords"];
[userDefaults synchronize];
}
and
-(void)viewDidLoad
{
NSArray *array = [[NSUserDefaults standardUserDefaults] objectForKey:#"Keywords"];
if (!array) {
keyWordArray = [[NSMutableArray alloc] init];
} else {
keyWordArray = [NSMutableArray arrayWithArray:nameArray];
}
}
Since you are overriding your
[userDefaults setObject:keyWordField.text forKey:#"Keywords"];
every then and there your every object in the array will be referring to your [userDefaults setObject:keyWordField.text forKey:#"Keywords"]; object thats y the problem comes
Because if you are navigate to another viewController. since the your user default value save in second only.
After pop to back through viewDidLoad is loaded. so far its have second string only save in User Default.
that way it display second only.
You code is overwrite the last value and remove previous values from NSUserDefault. You have to use array to stored all value and you have save array into NSUserDefault.
NSMutableArray *aryDataDefault = [[NSUserDefaults standardUserDefaults] valueForKey:#"YourKey"];
[aryDataDefault addObject:textfield.text];
[[NSUserDefaults standardUserDefaults] setObject:aryDataDefault forKey:#"YourKey"];
[[NSUserDefaults standardUserDefaults] synchronize];
I would like to stop my music playing from another view by using delegates. I already have that setup and i know there is this option...
- (void)viewWillDisappear:(BOOL)animated{
[player stop]; ///(my players name here and command to stop the player)
}
However i do not want to use that function because i have the music playing throughout. I have already added code to ensure my player does not overlap. But when i do want to stop my music i want to do so in a different view. I have tried the '[player stop];' function when the delegate is called but it does not work.
Can anyone help?
Thanks in advanced...
EDIT
HERE IS THE CODE FOR MY OPTIONS PAGE.H FILE:
#protocol onHandlerDelegate <NSObject>
- (void)off:(BOOL)success;
- (void)on:(BOOL)success;
-(void)volumeValueChange:(UISlider *)sender;
#end
#import <UIKit/UIKit.h>
#interface OptionsPage : UIViewController{
IBOutlet UISlider *VolumeSlider;
NSTimer *VolumeTimer;
IBOutlet UISwitch *onoroffmusic;
}
-(IBAction) UIBarButtonItem:(id)sender;
-(IBAction) SwitchMusic:(id)sender;
-(IBAction)changevolume:(id)sender;
#property (nonatomic, retain) UISwitch *onoroffmusic;
#property (nonatomic, strong) id<onHandlerDelegate> delegatePpty1;
#end
HERE IS MY OPTIONS PAGE .M FILE:
#import "OptionsPage.h"
#import "ViewController.h"
#interface OptionsPage ()
#end
#implementation OptionsPage
#synthesize onoroffmusic;
#synthesize delegatePpty1;
- (IBAction)changevolume:(id)sender{
int volume = VolumeSlider.value;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[NSNumber numberWithInt:volume] forKey:#"volume"];
[defaults synchronize];
[[self delegatePpty1]volumeValueChange:(VolumeSlider)];
}
-(IBAction) SwitchMusic:(id)sender{
if (onoroffmusic.on) {
[[self delegatePpty1] on:YES];
printf("done");
onoroffmusic.on = YES;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults removeObjectForKey:#"off"];
[defaults setObject:[NSNumber numberWithBool:YES] forKey:#"on"];
[defaults synchronize];
}
else {
/// do nothing
[[self delegatePpty1] off:YES];
printf("off");
onoroffmusic.on = NO;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults removeObjectForKey:#"on"];
[defaults setObject:[NSNumber numberWithBool:YES] forKey:#"off"];
[defaults synchronize];
ViewController *home = [[ViewController alloc] initWithNibName:nil bundle:nil];
[home.player stop];
}
}
-(IBAction) UIBarButtonItem:(id)sender{
ViewController *Backbutton = [[ViewController alloc] initWithNibName:nil bundle:nil];
[self presentViewController:Backbutton animated:YES completion:nil];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad{
VolumeSlider.value = 0.3;
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSObject * object = [prefs valueForKey:#"volume"];
if(object == nil){
VolumeSlider.value = 0.3;
}
else{
VolumeSlider.value = [[[NSUserDefaults standardUserDefaults] objectForKey:#"volume"] intValue];
}
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSUserDefaults *defaults2 = [NSUserDefaults standardUserDefaults];
BOOL restoredBoolValue2 = [[defaults2 objectForKey:#"off"] boolValue];
BOOL restoredBoolValue1 = [[defaults2 objectForKey:#"on"] boolValue];
if (restoredBoolValue2) {
////donothing
onoroffmusic.on = FALSE;
}
if (restoredBoolValue1) {
////donothing
onoroffmusic.on = TRUE;
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
Within the two files i declare a delegate and my switches. Now just to receive that delegate in my view controller:
MY VIEWCONNTROLLER .H FILE:
#import "OptionsPage.h"
#interface ViewController : UIViewController <onHandlerDelegate>{
AVAudioPlayer *player;
}
#property (nonatomic, retain) AVAudioPlayer *player;
#end
HERE IS MY .M FILE:
Firstly I
#synthesize player;
Then check if my delegates have been called by using:
-(void)volumeValueChange:(UISlider *)sender
{
if (sender.value > 0.3) {
player.volume = sender.value;
}
else{
player.volume = 0.3;
}
}
-(void)on:(BOOL)success{
NSLog(#"Delegate Method Called");
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[NSNumber numberWithBool:YES] forKey:#"mykey1"];
[self play];
[player play];
}
-(void)off:(BOOL)success{
NSLog(#"Delegate Method Called");
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults removeObjectForKey:#"mykey1"];
[defaults setObject:[NSNumber numberWithBool:YES] forKey:#"mykey"];
[player stop];
player = nil;
[defaults removeObjectForKey:#"music"];
}
I then load the bool value of my nsuserdefults by using this:
- (void)viewDidLoad
{
if ([[NSUserDefaults standardUserDefaults] stringForKey:#"mykey"] == nil ) {
if ([[NSUserDefaults standardUserDefaults] stringForKey:#"music"] == nil) {
[self play];
}
}
}
NSUserDefaults *defaults2 = [NSUserDefaults standardUserDefaults];
BOOL restoredBoolValue2 = [[defaults2 objectForKey:#"mykey"] boolValue];
if (restoredBoolValue2) {
////donothing
[player stop];
}
BOOL restoredBoolValue1 = [[defaults2 objectForKey:#"mykey1"] boolValue];
if (restoredBoolValue1){
[self play];
}
And i have my play void function
-(void)play{
if ([[NSUserDefaults standardUserDefaults] stringForKey:#"music"] == nil) {
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:#"%#/Music.mp3", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
player.numberOfLoops = -1;
[player play];
player.volume = 0.3;
player.currentTime = 0.0;
[[NSUserDefaults standardUserDefaults] setObject:#"-" forKey:#"music"];
}
else {
[player stop];
}
}
and lastly in my app delegate.m file i :
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
[[NSUserDefaults standardUserDefaults] setObject:nil forKey:#"music"];
}
Make player a property and stop it like this:
[anotherView.player stop];
First you need to change onHandlerDelegate from strong to weak because it is a delegate.
Secondly you need an instance of OptionsPage on the second view controller and you need to implement the delegate and do optionPage.delegate = self after it this will work.
Passing data just isn't doing the trick...I need to pull string data from a view controller when a function in the AppDelegate is called. Here's the code:
In App Delegate:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
AMViewController *viewController = [[AMViewController alloc] initWithNibName:#"AMViewController" bundle:nil];
self.xpData = viewController.xpLabel.text;
NSLog(#"Value of xpString in AD: %#", self.xpData);
}
In my ViewController, I'm not using an action to pass/retrieve the string. I'm basically pulling it from the ViewController when the user hits the home button. I'm doing this because I'd like to save my data on exit. Thanks!
In your AppDelegate.h
#property (atomic, copy) NSString *yourString;
Where you have changed xpLabel.text, do this
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.yourString = xpLabel.text;
Now in
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(#"Value of xpString in AD: %#", self.yourString);
}
Another Method
Set your value in AMViewController class like this
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:xpLabel.text forKey:#"yourkey"];
[prefs synchronize];
Get your Value in applicationDidEnterBackground like this
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
yourString = [prefs stringForKey:#"yourkey"];
Did you tried working with NSNotificationCenter
Or shared delegate:
http://www.roostersoftstudios.com/2011/04/12/simple-delegate-tutorial-for-ios-development/
http://coderchrismills.wordpress.com/2011/05/05/basic-delegate-example/
I have used this method for logout facebook in app
- (void)fbDidLogout {
// Remove saved authorization information if it exists
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:#"FBAccessTokenKey"]) {
[defaults removeObjectForKey:#"FBAccessTokenKey"];
[defaults removeObjectForKey:#"FBExpirationDateKey"];
[defaults synchronize];
}
NSLog(#"logout success!");
}
This method has been invoked, but when I relaunch app the facebook still know about my latest authorization.
My full implementation
I create singleton object for facebook instance.
this is my manager .h
#import <Foundation/Foundation.h>
#import "FBConnect.h"
#interface FacebookManager : NSObject <FBSessionDelegate> {
Facebook *facebook;
}
#property (nonatomic, strong) Facebook *facebook;
+ (FacebookManager *)sharedInstance;
- (void)initWithAppID:(NSString *)appID;
#end
this is singleton facebookmanager .m
#import "FacebookManager.h"
#implementation FacebookManager
#synthesize facebook;
static FacebookManager *_sharedInstance = nil;
+ (FacebookManager *)sharedInstance {
#synchronized(self) {
if (!_sharedInstance) {
_sharedInstance = [[FacebookManager alloc] init];
}
}
return _sharedInstance;
}
- (void)initWithAppID:(NSString *)appID {
facebook = [[Facebook alloc] initWithAppId:appID andDelegate:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:#"FBAccessTokenKey"]
&& [defaults objectForKey:#"FBExpirationDateKey"]) {
facebook.accessToken = [defaults objectForKey:#"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:#"FBExpirationDateKey"];
}
if (![facebook isSessionValid]) {
[facebook authorize:nil];
}
}
- (void)fbDidLogout {
// Remove saved authorization information if it exists
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:#"FBAccessTokenKey"]) {
[defaults removeObjectForKey:#"FBAccessTokenKey"];
[defaults removeObjectForKey:#"FBExpirationDateKey"];
[defaults synchronize];
}
NSLog(#"logout success!");
}
#end
in appDelegate I make next:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
fbManager = [FacebookManager sharedInstance];
[fbManager initWithAppID:#"myappid"];
... (some other code)
}
also add this code to app delegate:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [fbManager.facebook handleOpenURL:url];
}
- (void)fbDidLogin {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[fbManager.facebook accessToken] forKey:#"FBAccessTokenKey"];
[defaults setObject:[fbManager.facebook expirationDate] forKey:#"FBExpirationDateKey"];
[defaults synchronize];
}
In other view controller I call this method for logout:
- (IBAction)logoutFacebook:(id)sender {
FacebookManager *fbManager = [FacebookManager sharedInstance];
[fbManager.facebook logout];
}
also in plist I have add needed url scheme.
Modify the Facebook.m code to this, which works for me.
-(void)logout:(id)delegate {
self.sessionDelegate = delegate;
[_accessToken release];
_accessToken = nil;
[_expirationDate release];
_expirationDate = nil;
NSHTTPCookieStorage *cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSArray *facebookCookies = [cookies cookiesForURL:[NSURL URLWithString:#"http://login.facebook.com"]];
for (NSHTTPCookie* cookie in facebookCookies){
[cookies deleteCookie:cookie];
}
//Adds this one.
for (NSHTTPCookie *_cookie in cookies.cookies){
NSRange domainRange = [[_cookie domain] rangeOfString:#"facebook"];
if(domainRange.length > 0){
[cookies deleteCookie:_cookie];
}
}
if ([self.sessionDelegate respondsToSelector:#selector(fbDidLogout)]){
[_sessionDelegate fbDidLogout];
}
}
What do you mean by "when I relaunch app the facebook still know about my latest authorization" ? Does this mean your FB accesstoken is still valid? You still see the userdefaults values? What exactly?
If you mean that when you trigger the FB login again, it automatically logs you in again, then yes if you have the Facebook APP installed in iOS, the user will have to logout from the FB app manually to switch an account.
If the FB app is not installed, then yes the SSO should prompt the user to login again after initiating a logout.
That seems to be the way the ios sdk api with sso/oauth 2.0 works. I have not been able to logout completely even after clearing the tokens and I have not been able to switch users from the App. Got to go to the FB app to switch users
As a workaround, change the line in Facebook.m and disable the safariAuth
// [self authorizeWithFBAppAuth:YES safariAuth:YES];
[self authorizeWithFBAppAuth:NO safariAuth:NO]
But then you have to type in the username and password everytime you authorize.
In Facebook.m, add the following code to remove cookies at m.facebook.com domain.
- (void)invalidateSession {
...
NSArray* facebookMCookies = [cookies cookiesForURL:
[NSURL URLWithString:#"https://m.facebook.com"]];
for (NSHTTPCookie* cookie in facebookMCookies) {
[cookies deleteCookie:cookie];
}
...
}
I have tried with success this code:
NSFileManager *fm = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachesDirectory = [paths objectAtIndex:0];
NSLog(#"cache dir %#", cachesDirectory);
NSError *error = nil;
for (NSString *file in [fm contentsOfDirectoryAtPath:cachesDirectory error:&error]) {
BOOL success = [fm removeItemAtPath:[NSString stringWithFormat:#"%#/%#", cachesDirectory, file] error:&error];
if (!success || error) {
NSLog(#"Error delete file: %#, %#", file, error);
} else {
NSLog(#"Deleted file: %#", file);
}
}
I am trying to integrate Facebook to my iOS app with ARC. To use FB SDK, I have disabled ARC with "-fno-objc-arc" for those files. However, it still have EXC_BAD_ACCESS error and I need to change
#property(nonatomic, assign) id<FBSessionDelegate> sessionDelegate;
to
#property(nonatomic, retain) id<FBSessionDelegate> sessionDelegate;
The login is working now but the UITextView is not updated after login
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:#"FBAccessTokenKey"]
&& [defaults objectForKey:#"FBExpirationDateKey"]) {
[delegate facebook].accessToken = [defaults objectForKey:#"FBAccessTokenKey"];
[delegate facebook].expirationDate = [defaults objectForKey:#"FBExpirationDateKey"];
[defaults synchronize];
}
if (![[delegate facebook] isSessionValid])
{
[[delegate facebook] authorize:nil];
}
}
- (void)fbDidLogin
{
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[[delegate facebook] accessToken] forKey:#"FBAccessTokenKey"];
[defaults setObject:[[delegate facebook] expirationDate] forKey:#"FBExpirationDateKey"];
[defaults synchronize];
[[delegate facebook] requestWithGraphPath:#"me" andDelegate:self];
}
- (void)request:(FBRequest *)request didLoad:(id)result
{
if ([result isKindOfClass:[NSArray class]]) {
result = [result objectAtIndex:0];
}
if ([result objectForKey:#"name"]) {
self.uitextview.text = [result objectForKey:#"name"];
}
}
I have checked that "[result objectForKey:#"name"]" will return a result but "self.uitextview" is not recognized.
How do I update a UITextView after successful login?
Found out that the ViewController init in Appdelegate can't be used as shown in Facebook Hackbook sample.
Replace with the following declaration:
UITabBarController *tabBarController = (UITabBarController *) self.window.rootViewController;
ViewController *viewcontroller = [[tabBarController viewControllers] objectAtIndex:4];
http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1