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

The Archive Base Latest Questions

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

Hey..i have the following method in cocoa.. -(void)startUploadWithContainerName:(NSString *)containerName { //Make an object of

  • 0

Hey..i have the following method in cocoa..

-(void)startUploadWithContainerName:(NSString *)containerName
{
//Make an object of NSFileManager and Fetch an array of local folder contents and cloud folder contents
NSFileManager *uploadManager=[[NSFileManager alloc] init];
NSString *uploadPath=[[[NSString alloc] initWithString:@"~/Cloud Briefcase"] stringByExpandingTildeInPath];
NSError *err;
NSArray *uploadFolderContents=[uploadManager contentsOfDirectoryAtPath:uploadPath error:&err];
ASICloudFilesObjectRequest *cloudList = [ASICloudFilesObjectRequest listRequestWithContainer:containerName];
[cloudList startSynchronous];
NSArray *cloudFolderContents = [cloudList objects];

[cloudList release];
[uploadManager release];

NSLog(@"%lu",[uploadFolderContents count]);
NSLog(@"\n%@\n\n%@",cloudFolderContents,uploadFolderContents);
NSString *notFoundPath;
NSString *foundPath;
NSString *foundCloudMatch;
NSDate *cloudUploadDate;

for (int j=1; j<[uploadFolderContents count]; j++) {
    int i=0;
    for (int k=0; k<[cloudFolderContents count]; k++) {
        if ([[[cloudFolderContents objectAtIndex:k] name] isEqualToString:[uploadFolderContents objectAtIndex:j]]) {
            i=1;
            foundPath=[uploadFolderContents objectAtIndex:j];
            foundCloudMatch=[cloudFolderContents objectAtIndex:k];
            cloudUploadDate=[[cloudFolderContents objectAtIndex:k] lastModified];
            break;
        }
        else{
            i=0;
            notFoundPath=[uploadFolderContents objectAtIndex:j];
            continue;
        }
    }

    if (i==1) {
        NSLog(@"Found In Cloud: %@",foundPath);
        NSString *uploadPath=[[NSString stringWithFormat:@"~/Cloud Briefcase/%@",foundPath] stringByExpandingTildeInPath];
        NSTimeZone *tCST=[NSTimeZone timeZoneWithAbbreviation:@"CST"];
        NSInteger cloudDifference=[tCST secondsFromGMTForDate:cloudUploadDate];

        NSFileManager *typeManager=[[NSFileManager alloc] init];
        NSError *Er;
        NSDictionary *propertiesOfUploadFile=[typeManager attributesOfItemAtPath:uploadPath error:&Er];

        NSDate *localUploadDate=[propertiesOfUploadFile objectForKey:NSFileModificationDate];

        NSInteger sourceUploadDifference=[[NSTimeZone systemTimeZone] secondsFromGMTForDate:localUploadDate];


        NSLog(@"Local Date %@",localUploadDate);
        NSLog(@"Local Difference %ld",sourceUploadDifference);
        NSTimeInterval diff=sourceUploadDifference-cloudDifference;
        NSTimeInterval sDiff=sourceUploadDifference;
        NSDate *lDate=[[NSDate alloc] initWithTimeInterval:sDiff sinceDate:localUploadDate];
        NSDate *comparisonDate=[[NSDate alloc] initWithTimeInterval:diff sinceDate:cloudUploadDate];
        NSLog(@"\nSDiff Value %@",lDate);
        NSLog(@"Comparison Date %@",comparisonDate);

        [localUploadDate release];
        [propertiesOfUploadFile release];
        [typeManager release];
        [tCST release];

        if ([comparisonDate compare:lDate]==NSOrderedAscending) {
            [comparisonDate release];
            [lDate release];
            NSLog(@"Got It");
            NSString *escString=[foundPath stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
            ASICloudFilesObjectRequest *request = 
            [ASICloudFilesObjectRequest putObjectRequestWithContainer:containerName objectPath:escString contentType:@"file" file:uploadPath metadata:nil etag:nil];
            [request startSynchronous];
            NSLog(@"Uploaded %@",foundPath);
        }



    }
    else{
        NSLog(@"Not Found In Cloud: %@",notFoundPath);
        NSString *uploadPath=[[NSString stringWithFormat:@"~/Cloud Briefcase/%@",notFoundPath] stringByExpandingTildeInPath];
        //          NSLog(@"%@",uploadPath);


        NSString *escString=[notFoundPath stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
        NSLog(@"URL ENCODED VALUE: %@",escString);

        ASICloudFilesObjectRequest *request = 
        [ASICloudFilesObjectRequest putObjectRequestWithContainer:containerName objectPath:escString contentType:@"file" file:uploadPath metadata:nil etag:nil];
        [request startSynchronous];
        NSLog(@"Upload Complete");
    }
}
[uploadPath release];

[cloudList release];
[uploadFolderContents release];

 }

But it hangs showing the exception

Received Signal EXC_BAD_ACCESS

Can anyone clear the issue out? the exception occurs at NSLog(@”Found In Cloud: %@”,foundPath);

  • 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-26T00:24:33+00:00Added an answer on May 26, 2026 at 12:24 am

    Typically you would set the environment variable NSZombieEnabled to YES and then troubleshoot the issue.
    In your case I see that you have declared pointers without pointing to any object which is dangerous. Running your code in Clang Analyzer would report it as warning.
    Set those pointers to nil. You have declared string pointer but in your for loop if the “if” is not true then it goes to else where foundPath is never pointed to anything and you tried to access it in if(i==1)

    Update:
    Also consider Lou Franco ‘s answer. He is correct too. You don’t own cloudList object. It is autoreleased and you are over-releasing it by passing release message to cloudList object [cloudList release].
    In your case it might not crash instantly when you release it because control is in same loop. Once the current threads autorelease pool is drained your code will crash with EXC_BAD_ACCESS.

    ASICloudFilesObjectRequest *cloudList = [ASICloudFilesObjectRequest listRequestWithContainer:containerName];
    [cloudList startSynchronous];
    NSArray *cloudFolderContents = [cloudList objects];
    [cloudList release];// Remove this line 
    

    Update2:

    NSString *uploadPath=[[[NSString alloc] initWithString:@"~/Cloud Briefcase"] stringByExpandingTildeInPath];
    

    Change the above to

    NSString *uploadPath=[[NSString stringWithFormat:@"~/Cloud Briefcase"] stringByExpandingTildeInPath];
    

    uploadPath in above line still points to autoreleased object. You are leaking a string you have created. Calling release is wrong. So remove [uploadPath release] and also [cloudList release] you are releasing it again and again. And why are you releasing obviously autoreleased object uploadFolderContents ? remove these three lines from your code:

    [uploadPath release];
    
    [cloudList release];
    [uploadFolderContents release];
    

    Update3: Fixed over-release issues. And updatePath in if block changed to updatePathLocal where there is a conflict with updatePath variable with scope of method.

    -(void)startUploadWithContainerName:(NSString *)containerName
    {
    //Make an object of NSFileManager and Fetch an array of local folder contents and cloud folder contents
    NSFileManager *uploadManager=[[NSFileManager alloc] init];
    NSString *uploadPath=[[NSString stringWithFormat:@"~/Cloud Briefcase"] stringByExpandingTildeInPath];
    NSError *err = nil;
    NSArray *uploadFolderContents=[uploadManager contentsOfDirectoryAtPath:uploadPath error:&err];
    ASICloudFilesObjectRequest *cloudList = [ASICloudFilesObjectRequest listRequestWithContainer:containerName];
    [cloudList startSynchronous];
    NSArray *cloudFolderContents = [cloudList objects];
    
    [uploadManager release];
    
    NSLog(@"%lu",[uploadFolderContents count]);
    NSLog(@"\n%@\n\n%@",cloudFolderContents,uploadFolderContents);
    NSString *notFoundPath = nil;
    NSString *foundPath = nil;
    NSString *foundCloudMatch = nil;
    NSDate *cloudUploadDate = nil;
    
    for (int j=1; j<[uploadFolderContents count]; j++) {
        int i=0;
        for (int k=0; k<[cloudFolderContents count]; k++) {
            if ([[[cloudFolderContents objectAtIndex:k] name] isEqualToString:[uploadFolderContents objectAtIndex:j]]) {
                i=1;
                foundPath=[uploadFolderContents objectAtIndex:j];
                foundCloudMatch=[cloudFolderContents objectAtIndex:k];
                cloudUploadDate=[[cloudFolderContents objectAtIndex:k] lastModified];
                break;
            }
            else{
                i=0;
                notFoundPath=[uploadFolderContents objectAtIndex:j];
                continue;
            }
        }
    
        if (i==1) {
            NSLog(@"Found In Cloud: %@",foundPath);
            NSString *uploadPathLocal=[[NSString stringWithFormat:@"~/Cloud Briefcase/%@",foundPath] stringByExpandingTildeInPath];
            NSTimeZone *tCST=[NSTimeZone timeZoneWithAbbreviation:@"CST"];
            NSInteger cloudDifference=[tCST secondsFromGMTForDate:cloudUploadDate];
    
            NSFileManager *typeManager=[[NSFileManager alloc] init];
            NSError *Er = nil;
            NSDictionary *propertiesOfUploadFile=[typeManager attributesOfItemAtPath:uploadPathLocal error:&Er];
    
            NSDate *localUploadDate=[propertiesOfUploadFile objectForKey:NSFileModificationDate];
    
            NSInteger sourceUploadDifference=[[NSTimeZone systemTimeZone] secondsFromGMTForDate:localUploadDate];
    
    
            NSLog(@"Local Date %@",localUploadDate);
            NSLog(@"Local Difference %ld",sourceUploadDifference);
            NSTimeInterval diff=sourceUploadDifference-cloudDifference;
            NSTimeInterval sDiff=sourceUploadDifference;
            NSDate *lDate=[[NSDate alloc] initWithTimeInterval:sDiff sinceDate:localUploadDate];
            NSDate *comparisonDate=[[NSDate alloc] initWithTimeInterval:diff sinceDate:cloudUploadDate];
            NSLog(@"\nSDiff Value %@",lDate);
            NSLog(@"Comparison Date %@",comparisonDate);
    
            [typeManager release];
    
            if ([comparisonDate compare:lDate]==NSOrderedAscending) {
                [comparisonDate release];
                [lDate release];
                NSLog(@"Got It");
                NSString *escString=[foundPath stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
                ASICloudFilesObjectRequest *request = 
                [ASICloudFilesObjectRequest putObjectRequestWithContainer:containerName objectPath:escString contentType:@"file" file:uploadPath metadata:nil etag:nil];
                [request startSynchronous];
                NSLog(@"Uploaded %@",foundPath);
            }
        }
        else{
            NSLog(@"Not Found In Cloud: %@",notFoundPath);
            NSString *uploadPathLocal=[[NSString stringWithFormat:@"~/Cloud Briefcase/%@",notFoundPath] stringByExpandingTildeInPath];
            //          NSLog(@"%@",uploadPath);
    
    
            NSString *escString=[notFoundPath stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
            NSLog(@"URL ENCODED VALUE: %@",escString);
    
            ASICloudFilesObjectRequest *request = 
            [ASICloudFilesObjectRequest putObjectRequestWithContainer:containerName objectPath:escString contentType:@"file" file:uploadPathLocal metadata:nil etag:nil];
            [request startSynchronous];
            NSLog(@"Upload Complete");
        }
     }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey - I have the following method on my UITableView controller public void RemoveEventFromList(Event
Hey Guys, i have created the following Menu Structure: <div id=menu> <ul> <li><a href=#>Main
Hey all. I have a question on how to implement the following with Django.
Hey all, basically i have an empty AS3 fla file with just the following
Hey I have an array of hexadecimal colors and for each color in the
Hey guys, I have the following HTML structure that I am trying to pull
Hey guys. I have the following situation. I want to use a TypeDescriptor to
Hey people, i have a the following map* which is giving me lots of
hey guys, a php variable $html holds the following object... <object width=562 height=200> <param
Hey guys I have the following while loop which seems not to stop. It's

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.