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 1099363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:43:31+00:00 2026-05-17T00:43:31+00:00

I am probably not seeing something here, that is why I am asking for

  • 0

I am probably not seeing something here, that is why I am asking for help 🙂
Here is the deal I have a NSMutable array of items that fulfill the NSCoding protocol, but NSKeyedArchiver always fails to archive it… here is my object implementation:

@implementation YTVideo
@synthesize URL,thumb,titulo;

#pragma mark NSCoding
#define kTituloKey          @"titulo"
#define kURLKey     @"URL"
#define kThumbKey       @"thumb"

-(id)initWithData:(NSString *)ktitle :(UIImage *)kThumb :(NSURL *)kURL{
self.titulo = ktitle;
self.thumb = kThumb;
self.URL = kURL;

return self;
}

- (void) encodeWithCoder:(NSCoder *)encoder {
[encoder encodeObject:titulo forKey:kTituloKey];
[encoder encodeObject:URL forKey:kURLKey];
NSData *thumbData = UIImagePNGRepresentation(thumb);
[encoder encodeObject:thumbData forKey:kThumbKey];
}

- (id)initWithCoder:(NSCoder *)decoder {
NSString* ktitulo = [decoder decodeObjectForKey:kTituloKey];
NSURL* kURL = [decoder decodeObjectForKey:kURLKey];
NSData* kThumbdata = [decoder decodeObjectForKey:kThumbKey];
UIImage* kThumb=[UIImage imageWithData:kThumbdata];
return [self initWithData:ktitulo:kThumb:kURL];
}

@end

During the program execution I have a NSMutable array of those objects called videosArray.

then, eventually, I try:

NSString* path =[NSHomeDirectory() stringByAppendingPathComponent:@"teste.wrapit"];
NSLog(@"PATH =%@",path);
bool teste = [NSKeyedArchiver archiveRootObject:videosArray toFile:path];
NSLog(@"aramzenamento:%@",teste ? @"sucesso!" :@"Nope");
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:path];
NSLog(@"Arquivo armazenado existe?%@",fileExists ?@"Sim":@"Nao");

And I always get a fail on my boolean checks…
Any Ideas where I am completely wrong??
Thanks!!

  • 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-17T00:43:32+00:00Added an answer on May 17, 2026 at 12:43 am

    The problem you’re experiencing has nothing to do with NSKeyedArchiver. By the looks of it, you’re trying to archive your object at the root-level of your sandbox (the directory returned by NSHomeDirectory()). Try replacing the first line of the second block of code with

    NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    path = [path stringByAppendingPathComponent:@"teste.wrapit"];
    

    Another (perhaps cleaner) way to get the path of your Documents folder is to use the C function NSSearchPathForDirectoriesInDomains, which returns an array of paths that match the first argument:

    NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"teste.wrapit"];
    

    It’s worth pointing out that, on iOS, the function NSSearchPathForDirectoriesInDomain is guaranteed to return an NSArray with a single element when you use a built-in constant (like NSDocumentDirectory) for the first argument, so you can safely use objectAtIndex:0 on the array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.