Skip to content

Commit

Permalink
adding en namespace to category methods to avoid collisions with othe…
Browse files Browse the repository at this point in the history
…r categories
  • Loading branch information
mustafa committed Mar 15, 2013
1 parent 9e7db9b commit 348daee
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 25 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -23,7 +23,8 @@ You have a few options:

- Copy the evernote-sdk-ios source code into your Xcode project.
- Add the evernote-sdk-ios xcodeproj to your project/workspace.
- Build the evernote-sdk-ios as a static library and include the .h's and .a. (Make sure to add the `-ObjC` flag to your compiler flags if you choose this option.)
- Build the evernote-sdk-ios as a static library and include the .h's and .a. (Make sure to add the `-ObjC` flag to your "Other Linker flags" if you choose this option).
More info [here](http://developer.apple.com/library/ios/#technotes/iOSStaticLibraries/Articles/configuration.html#/apple_ref/doc/uid/TP40012554-CH3-SW2).
- Use [cocoapods](http://cocoapods.org), a nice Objective-C dependency manager. Our pod name is "Evernote-SDK-iOS".

### Link with frameworks
Expand Down
4 changes: 2 additions & 2 deletions SampleApp/MoreViewController.m
Expand Up @@ -44,7 +44,7 @@ - (IBAction)saveNewNote:(id)sender {
if([[EvernoteSession sharedSession] isEvernoteInstalled]) {
NSString* filePath = [[NSBundle mainBundle] pathForResource:@"evernote_logo_4c-sm" ofType:@"png"];
NSData *myFileData = [NSData dataWithContentsOfFile:filePath];
NSData *dataHash = [myFileData md5];
NSData *dataHash = [myFileData enmd5];
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];
NSMutableArray *resources = [NSMutableArray arrayWithObjects:resource,resource, nil];
Expand Down Expand Up @@ -100,7 +100,7 @@ - (IBAction)createBusinessNote:(id)sender {
EDAMLinkedNotebook* businessNotebook = linkedNotebooks[0];
NSString* filePath = [[NSBundle mainBundle] pathForResource:@"evernote_logo_4c-sm" ofType:@"png"];
NSData *myFileData = [NSData dataWithContentsOfFile:filePath];
NSData *dataHash = [myFileData md5];
NSData *dataHash = [myFileData enmd5];
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\"?>"
Expand Down
2 changes: 1 addition & 1 deletion SampleApp/iPadViewController.m
Expand Up @@ -130,7 +130,7 @@ - (IBAction)listBusinessNotebooks:(id)sender {
- (IBAction)createPhotoNote:(id)sender {
NSString* filePath = [[NSBundle mainBundle] pathForResource:@"evernote_logo_4c-sm" ofType:@"png"];
NSData *myFileData = [NSData dataWithContentsOfFile:filePath];
NSData *dataHash = [myFileData md5];
NSData *dataHash = [myFileData enmd5];
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\"?>"
Expand Down
2 changes: 1 addition & 1 deletion SampleApp/iPhoneViewController.m
Expand Up @@ -145,7 +145,7 @@ - (IBAction)listSharedNotes:(id)sender {
- (IBAction)createPhotoNote:(id)sender {
NSString* filePath = [[NSBundle mainBundle] pathForResource:@"evernote_logo_4c-sm" ofType:@"png"];
NSData *myFileData = [NSData dataWithContentsOfFile:filePath];
NSData *dataHash = [myFileData md5];
NSData *dataHash = [myFileData enmd5];
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\"?>"
Expand Down
6 changes: 3 additions & 3 deletions evernote-sdk-ios/Utilities/ENMLUtility.m
Expand Up @@ -56,7 +56,7 @@ + (NSString*) mediaTagWithDataHash:(NSData *)dataHash
if (mime == nil) {
mime = ENMIMETypeOctetStream;
}
NSString* dataHashHex = [dataHash lowercaseHexDigits];
NSString* dataHashHex = [dataHash enlowercaseHexDigits];
NSString* mediaTag = [NSString stringWithFormat:@"<%@ type =\"%@\" hash=\"%@\"/>",
ENMLTagMedia,
mime,
Expand Down Expand Up @@ -107,7 +107,7 @@ - (void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName na
}
else if([elementName isEqualToString:ENMLTagMedia] && self.resources) {
NSString *mediaHash = [attributeDict objectForKey:@"hash"];
NSData* dataHash = [NSData dataWithHexDigits:mediaHash];
NSData* dataHash = [NSData endataWithHexDigits:mediaHash];
EDAMResource *foundResource = nil;
for (EDAMResource* resource in self.resources) {
if([[[resource data] bodyHash] isEqualToData:dataHash]) {
Expand Down Expand Up @@ -177,7 +177,7 @@ - (void) writeImageTagForResource:(EDAMResource *)resource

NSMutableDictionary *imageAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
NSString *mime = [resource mime];
NSString* imgStr = [NSString stringWithFormat:@"data:%@;base64,%@",mime,[[[resource data] body] base64Encoding]];
NSString* imgStr = [NSString stringWithFormat:@"data:%@;base64,%@",mime,[[[resource data] body] enbase64Encoding]];

[imageAttributes setObject:imgStr
forKey:@"src"];
Expand Down
6 changes: 3 additions & 3 deletions evernote-sdk-ios/Utilities/NSData+EvernoteSDK.h
Expand Up @@ -37,14 +37,14 @@
@returns The MD5 hash
*/
- (NSData *) md5;
- (NSData *) enmd5;

/** hex representation of data (used in ENML media)
@returns The hex representation in lower case
*/
- (NSString *) lowercaseHexDigits;
- (NSString *) enlowercaseHexDigits;

+ (NSData *) dataWithHexDigits: (NSString *) hexDigits;
+ (NSData *) endataWithHexDigits: (NSString *) hexDigits;

@end
6 changes: 3 additions & 3 deletions evernote-sdk-ios/Utilities/NSData+EvernoteSDK.m
Expand Up @@ -32,15 +32,15 @@

@implementation NSData (EvernoteSDK)

- (NSData *) md5
- (NSData *) enmd5
{
unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];
CC_MD5(self.bytes, (CC_LONG)self.length, md5Buffer);
NSMutableData * md5Data = [NSMutableData dataWithBytes:md5Buffer length: CC_MD5_DIGEST_LENGTH];
return md5Data;
}

- (NSString *) lowercaseHexDigits
- (NSString *) enlowercaseHexDigits
{
unsigned const char * bytes = [self bytes];

Expand All @@ -54,7 +54,7 @@ - (NSString *) lowercaseHexDigits
return hex;
}

+ (NSData *) dataWithHexDigits: (NSString *) hexDigits
+ (NSData *) endataWithHexDigits: (NSString *) hexDigits
{
if (!hexDigits) {
return nil;
Expand Down
6 changes: 3 additions & 3 deletions evernote-sdk-ios/Utilities/NSDataBase64Additions.h
Expand Up @@ -4,9 +4,9 @@
// Original development by Dave Winer.

@interface NSData (NSDataBase64Additions)
+ (NSData *) dataWithBase64EncodedString:(NSString *) string;
+ (NSData *) endataWithBase64EncodedString:(NSString *) string;
- (id) initWithBase64EncodedString:(NSString *) string;

- (NSString *) base64Encoding;
- (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength;
- (NSString *) enbase64Encoding;
- (NSString *) enbase64EncodingWithLineLength:(unsigned int) lineLength;
@end
8 changes: 4 additions & 4 deletions evernote-sdk-ios/Utilities/NSDataBase64Additions.m
Expand Up @@ -12,7 +12,7 @@
'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' };

@implementation NSData (NSDataBase64Additions)
+ (NSData *) dataWithBase64EncodedString:(NSString *) string {
+ (NSData *) endataWithBase64EncodedString:(NSString *) string {
return [[NSData allocWithZone:nil] initWithBase64EncodedString:string];
}

Expand Down Expand Up @@ -84,11 +84,11 @@ - (id) initWithBase64EncodedString:(NSString *) string {

#pragma mark -

- (NSString *) base64Encoding {
return [self base64EncodingWithLineLength:0];
- (NSString *) enbase64Encoding {
return [self enbase64EncodingWithLineLength:0];
}

- (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength {
- (NSString *) enbase64EncodingWithLineLength:(unsigned int) lineLength {
const unsigned char *bytes = [self bytes];
NSMutableData * resultData = [NSMutableData dataWithCapacity: [self length]*1.5];
unsigned long ixtext = 0;
Expand Down
4 changes: 2 additions & 2 deletions evernote-sdk-ios/Utilities/NSDate+EDAMAdditions.h
Expand Up @@ -38,12 +38,12 @@
@param edamTimestamp The timestamp obtained from an Evernote API data structure.
@return The equivalent NSDate
*/
+ (NSDate *) dateFromEDAMTimestamp: (int64_t) edamTimestamp;
+ (NSDate *) endateFromEDAMTimestamp: (int64_t) edamTimestamp;


/**
* Convert an NSDate to an edam timestamp
*/
- (int64_t) edamTimestamp;
- (int64_t) enedamTimestamp;

@end
4 changes: 2 additions & 2 deletions evernote-sdk-ios/Utilities/NSDate+EDAMAdditions.m
Expand Up @@ -31,12 +31,12 @@

@implementation NSDate (EDAMAdditions)

+ (NSDate *) dateFromEDAMTimestamp: (int64_t) edamTimestamp
+ (NSDate *) endateFromEDAMTimestamp: (int64_t) edamTimestamp
{
return [NSDate dateWithTimeIntervalSince1970: ((double)edamTimestamp)/1000.0];
}

- (int64_t) edamTimestamp
- (int64_t) enedamTimestamp
{
return trunc([self timeIntervalSince1970]) * 1000;
}
Expand Down

0 comments on commit 348daee

Please sign in to comment.