Jump to content

Welcome! You're currently a Guest.

If you'd like to join in the Discussion, or access additional features in our forums, please sign in with your Evernote Account here. Have an Evernote Account but forgot your password? Reset it! Don't have an account yet? Create One! You'll need to set your Display Name before your first post.

Photo

Evernote iOS ARC compliant SDK error

ios

  • Please log in to reply
4 replies to this topic

#1 David Chevenement

David Chevenement

  • Pip
  • Title: Member
  • Group: Members
  • 48 posts

Posted 18 February 2013 - 06:26 PM

Dear Evernote team,

 

We have been upgrading to the latest SDK that is ARC compliant.

 

It seems there are a few compiler analysis warning.

 

Indeed, checking the ENGCOAuth files, there are probably 2 issues.

For method pcen and nonce, you're actually returning with a (__bridge) statement, meaning that the current ownership you have from your CF method is a retain, so you have the ownership, hence it leads to a leak when leaving the method.

 

In our opinion, it should be a (__bridge_transfer) as you want to transfer ownership to ARC so that it releases the CF object when leaving the method.

Switching to this actually silents all analysis issues.

 

Please advise as on what we do.

 

Kind regards,

David

BeesApps

 



#2 Mustafa

Mustafa

  • Title: Browncoat
  • Group: Evernote Employee
  • 348 posts

Posted 18 February 2013 - 06:33 PM

Hi,

 

All the analyzer issues have been fixed in this branch : https://github.com/e...ree/mustafa-dev . We will be releasing it out very soon. In case you need it urgently, please use this branch.

 

Thanks,

Mustafa



#3 David Chevenement

David Chevenement

  • Pip
  • Title: Member
  • Group: Members
  • 48 posts

Posted 20 February 2013 - 06:31 PM

Dear Mustafa,

 

We integrated the version you're mentioning and now have an exception error with our method to post to Evernote which was working perfectly fine right before.

Exception is: 

*** Evernote API Exception -[NSConcreteMutableData dataUsingEncoding:]: unrecognized selector sent to instance 0x2154f3a0

 

Looking at our code, it seems to crash on the hash we provide to add EDAMData

 

 

EDAMData * imageData = [[EDAMData alloc] initWithBodyHash:[hash dataUsingEncoding: NSASCIIStringEncoding] size:[imageNSData length] body:imageNSData];

 

 

Please advise as we obviously did not modify anything.



#4 Mustafa

Mustafa

  • Title: Browncoat
  • Group: Evernote Employee
  • 348 posts

Posted 20 February 2013 - 06:41 PM

Please check the sample code on how to create a photo note. It's in the file : iPadViewController/iPhoneViewController. Here is the code snippet :

 


- (IBAction)createPhotoNote:(id)sender {
    NSString* filePath = [[NSBundle mainBundle] pathForResource:@"evernote_logo_4c-sm" ofType:@"png"];
    NSData *myFileData = [NSData dataWithContentsOfFile:filePath];
    NSData *dataHash = [myFileData md5];
    EDAMData *edamData = [[EDAMData alloc] initWithBodyHash:dataHash size:myFileData.length body:myFileData];
    EDAMResource* resource = [[EDAMResource alloc] initWithGuid:nil noteGuid:nil data:edamData mime:@"image/png" width:0 height:0 duration:0 active:0 recognition:0 attributes:nil updateSequenceNum:0 alternateData:nil];
    NSString *noteContent = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                             "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">"
                             "<en-note>"
                             "<span style=\"font-weight:bold;\">Hello photo note.</span>"
                             "<br />"
                             "<span>Evernote logo :</span>"
                             "<br />"
                             "%@"
                             "</en-note>",[ENMLUtility mediaTagWithDataHash:dataHash mime:@"image/png"]];
    NSMutableArray* resources = [NSMutableArray arrayWithArray:@[resource]];
    EDAMNote *newNote = [[EDAMNote alloc] initWithGuid:nil title:@"Test photo note" content:noteContent contentHash:nil contentLength:noteContent.length created:0 updated:0 deleted:0 active:YES updateSequenceNum:0 notebookGuid:nil tagGuids:nil resources:resources attributes:nil tagNames:nil];
    [[EvernoteNoteStore noteStore] createNote:newNote success:^(EDAMNote *note) {
        NSLog(@"Note created successfully.");
    } failure:^(NSError *error) {
        NSLog(@"Error creating note : %@",error);
    }];
}


#5 David Chevenement

David Chevenement

  • Pip
  • Title: Member
  • Group: Members
  • 48 posts

Posted 20 February 2013 - 06:48 PM

Dear Mustafa, 

 

pb solved, you implemented an md5 method returning with an NSData (you should by the way watch out, you're returning a mutable version from your version) where we had an md5 method with an NSString return value that we were then encoding.

 

Thanks

David







Also tagged with one or more of these keywords: ios

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Clip to Evernote