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

  • Home
  • SEARCH
  • 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 7786669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:27:16+00:00 2026-06-01T20:27:16+00:00

I found a code snippet here , which I wanted to use, but I

  • 0

I found a code snippet here, which I wanted to use, but I can’t figure out how to make it back “to string” and see if it works…

// some strings for test
NSString *cpu = [[NSString alloc] initWithFormat:@"%.0f", [_cpuSlider value]];
NSString *ram = [[NSString alloc] initWithFormat:@"%.0f", [_ramSlider value]];
NSString *hdd = [[NSString alloc] initWithFormat:@"%.0f", [_hddSlider value]];

// put them into dictionary
NSDictionary *test = [NSDictionary dictionaryWithObjectsAndKeys:cpu, @"CPU", ram, @"RAM", hdd, @"HDD", nil];
// start of the code from page above
NSMutableData *myData = [[NSMutableData alloc]init];  
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc]initForWritingWithMutableData:myData];  
[archiver encodeObject:test forKey:@"MyKEY"];  
[archiver finishEncoding];  
id testJson = [NSJSONSerialization JSONObjectWithData:myData options:0 error:nil];
// end of code

// HERE I'd like know what to put in to see it as a string..e.g. { "CPU"=value; etc...}
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"MLIA" message:????? delegate:nil cancelButtonTitle:@"Zavřít" otherButtonTitles: nil];
[av show];

Thanks a lot!

  • 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-06-01T20:27:17+00:00Added an answer on June 1, 2026 at 8:27 pm

    NSKeyedArchiver doesn’t produce JSON (AFAIK), so I don’t know how that linked example could possibly work. If you want to JSON-encode a dictionary, you would use +dataWithJSONObject:options:error::

    NSError *err;
    NSData *json = [NSJSONSerialization dataWithJSONObject:test options:0 error:&err];
    NSAssert1(json, @"Error: %@", err);
    
    // If not using ARC, remember to (auto)release repr.
    NSString *repr = [[NSString alloc] initWithData:json encoding:NSUTF8StringEncoding];
    
    [[UIAlertView …] … message:repr …];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this thread I found a JavaScript code snippet which I want to use.
I have found some code snippet in the internet. But it is missing some
VS 2008 I have this code snippet I found on a VB website. But
Here is the snippet of my code which is causing this error: for (a=0;
I'm reading Programming Perl , and I found this code snippet: sub new {
I found this snippet of code I am having trouble trying to find a
I've found this snippet of code on the net. It sets up an NSMutableArray
I found the code from the net in which i cant understand this line:-
I found this code for alphanumeric check (Letters, numbers, spaces or underscores) but I
i found this code at activestate, it takes a string and prints permutations of

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.