Cocoa Maker
Cocoa Maker 7 - Libraries and Frameworks

Cocoa Maker 7 - Libraries and Frameworks

Cocoa Maker

About this episode

James (MrGeckosMedia.com), joined by, Eduardo (MegaEduX.com), and Nick, explains libraries and frameworks. 11:56 Example code from episode. Libraries Libraries included, /usr/lib/libcrypto.dylib and /usr/lib/libssl.dylib #import <Foundation/Foundation.h> #import <openssl/evp.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSString *string = @"Hello"; OpenSSL_add_all_algorithms(); unsigned char outbuf[EVP_MAX_MD_SIZE]; unsigned int templen, inlen = [string length]; const char *input = [string UTF8String]; EVP_MD_CTX ctx; const EVP_MD *digest = EVP_md5(); if(!digest) { NSLog(@"cannot get digest with name MD5"); return 1; } EVP_MD_CTX_init(&ctx); EVP_DigestInit(&ctx,digest); if(!EVP_DigestUpdate(&ctx,input,inlen)) { NSLog(@"EVP_DigestUpdate() failed!"); EVP_MD_CTX_cleanup(&ctx); return 1; } if (!EVP_DigestFinal(&ctx, outbuf, &templen)) { NSLog(@"EVP_DigesttFinal() failed!"); EVP_MD_CTX_cleanup(&ctx); return 1; } EVP_MD_CTX_cleanup(&ctx); NSMutableString *md5 = [NSMutableString string]; for (int i=0; i<templen; i++) { [md5 appendFormat:@"%x", outbuf[i]]; } NSLog(@"MD5 of %@ is %@", string, md5); [pool drain]; return 0; } Frameworks Frameworks included, AddressBook.framework #import <Foundation/Foundation.h> #import <AddressBook/AddressBook.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; ABAddressBook *addressBook = [ABAddressBook sharedAddressBook]; NSArray *people = [addressBook people]; for (int i=0; i<[people count]; i++) { ABPerson *person = [people objectAtIndex:i]; NSString *firstName = [person valueForProperty:kABFirstNameProperty]; NSString *lastName = [person valueForProperty:kABLastNameProperty]; NSString *name = nil; if (firstName!=nil) { name = firstName; if (lastName!=nil) name = [name stringByAppendingFormat:@" %@", lastName]; } if (name!=nil) NSLog(@"Person named: %@", name); } [pool drain]; return 0; } Keynote used in this Episode Keynote in PDF Format

More from Cocoa Maker

James (MrGeckosMedia.com), joined by, Eduardo (MegaEduX.com), and John (@ZimiPoder), shows how Dictionaries, Arrays and Property Lists works in Cocoa. 12:40 Example code from episode. #import <Foundat…

James (MrGeckosMedia.com), joined by, Noah (RockntheSweater.com), and Karl, explains how file managing works in c and cocoa. 7:49 Example code from episode. Files C Example #import <Foundation/Foundat…

James (MrGeckosMedia.com), joined by, Eduardo (MegaEduX.com), and Karl, teaches how loops, arguments, and goto works in Cocoa. 15:35 Example code from episode. Loops Example #import <Foundation/Founda…

James (MrGeckosMedia.com), joined by, Eduardo (MegaEduX.com), Martin (QueenZSoftware.com), John (@zimipoder), and Garrett, teaches how to read the documentation that comes with xcode. 10:48 Keynote us…

James (MrGeckosMedia.com), joined by, Eduardo (MegaEduX.com), Noah (RockntheSweater.com), and Martin (QueenZSoftware.com), teaches about the syntax of cocoa, how equations work in cocoa, how to do if…