Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6195239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:26:02+00:00 2026-05-24T03:26:02+00:00

Iam developing one applciation.In that application i used the both imageview and textview.And iam

  • 0

Iam developing one applciation.In that application i used the both imageview and textview.And iam used the NSUserdefaults for storing the imageview image value and textview text value.But when iam going to another page and coming to main page only imageview image data will be available in nsuserdefaults,textview text data is not avialable.So please tell me how to get the textview text data also by using nsuserdefaults

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:26:04+00:00Added an answer on May 24, 2026 at 3:26 am

    You should check your Key for spelling mistakes. By the way, just for reference,

    Methods of saving images to NSUserDefaults:

    Number 1: Saving and retrieving image directly:

    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    NSData *imageData = [NSKeyedArchiver archivedDataWithRootObject:imageView.image];
    [userDefaults setObject:imageData forKey:@"Image"];
    
    //Retrieving
    UIImage *image = (UIImage*)[NSKeyedUnarchiver unarchiveObjectWithData:[userDefaults objectForKey:@"Image"]];
    

    Number 2: Saving the image in documents directory and saving its path in NSUserDefaults:

    //Saving
    //Obtain the path for Documents Directory
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];      
    
    //Append Image name to the path
    NSString *imagePath = [[documentsDirectory stringByAppendingPathComponent:@"Image"] retain];  
    
    //Creating a file at this path
    NSFileManager *fileManager = [NSFileManager defaultManager]; 
    BOOL ok = [fileManager createFileAtPath:dataFilePath contents:nil attributes:nil];
    if (!ok) {
        NSLog(@"Error creating file %@", dataFilePath);
    } 
    else {
        //Writing image to the created file
        NSFileHandle *myFileHandle = [NSFileHandle fileHandleForWritingAtPath:imagePath];
    
        [myFileHandle writeData:UIImageJPEGRepresentation(imageView.image, 1.0)];
        [myFileHandle closeFile];
    }
    
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    if (userDefaults) {
    
        [userDefaults setObject:imagePath forKey:@"ImagePath"];
    
    }
    
    //Retrieving
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    NSString *imagePath = [userDefaults objectForKey:@"ImagePath"];
    NSFileHandle* fileHandle = [NSFileHandle fileHandleForReadingAtPath:dataFilePath];
    UIImage* loadedImage = [UIImage imageWithData:[fileHandle readDataToEndOfFile]];
    

    Method of saving text to NSUserDefaults:

    //Saving
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    [userDefaults setValue:textView.text forKey:@"Text"];
    
    //Retrieving
    textView.text = [userDefaults valueForKey:@"Text"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing one application in which comic font are used and that can
I am developing an application that will be used by many users in the
I am developing openGL application on iPad and i came up to one quite
I am developing an application in which for each method or event I used
I have this ajax web application I am developing that essentially calls the google
I am developing a small application in android in which i have few image
I'm about to start developing a new web application in CodeIgniter. In the past,
I am developing an android application where i need to enter multiple rows in
has anyone successfully used the jQuery ui.layout plugin to load jQuery mobile inside the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.