1/31/2010

Cocoa Maker 2 - Syntax

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 statements, functions, and classes.


33:56


Example code from episode.
Example 1 - If Statements and Equations
#import <Foundation/Foundation.h>

int times(int value, int by);

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int value = 1230;
    NSLog(@"Value: %d", value);
    NSLog(@"Value: %d", value%500);
    NSLog(@"Value: %d", value/100);
    NSLog(@"Value: %d", times(value, 4232));
    
    if (value>1242) {
        NSLog(@"%d is greater then 1242", value);
    } else if (value>=1242) {
        NSLog(@"%d is greater then or equal to 1242", value);
    } else if (value<1240) {
        NSLog(@"%d is less then 1242", value);
    } else if (value<=1240) {
        NSLog(@"%d is less then or equal to 1242", value);
    }
    [pool drain];
    return 0;
}

int times(int value, int by) {
    int returnValue = value*by;
    return returnValue;
}


Example 2 - Classes and Methods
#import <Foundation/Foundation.h>
#import "MGMCalculation.h"

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    MGMCalculation *calculation = [[MGMCalculation alloc] init];
    [calculation setAmount:572];
    [calculation setCurrencyExchange:3];
    int amount = [calculation calculate];
    NSLog(@"%d", amount);
    [calculation release];
    
    [pool drain];
    return 0;
}
MGMCalculation.h
#import <Foundation/Foundation.h>

@interface MGMCalculation : NSObject {
    int amount;
    int currencyExchange;
}
- (int)amount;
- (void)setAmount:(int)theAmount;

- (int)currencyExchange;
- (void)setCurrencyExchange:(int)theCurrencyExchange;

- (int)calculate;
@end
MGMCalculation.m
#import "MGMCalculation.h"

@implementation MGMCalculation
- (id)init {
    if (self = [super init]) {
        amount = 0;
        currencyExchange = 0;
    }
    return self;
}

- (int)amount {
    return amount;
}
- (void)setAmount:(int)theAmount {
    amount = theAmount;
}

- (int)currencyExchange {
    return currencyExchange;
}
- (void)setCurrencyExchange:(int)theCurrencyExchange {
    currencyExchange = theCurrencyExchange;
}

- (int)calculate {
    return amount*currencyExchange;
}
@end

Keynote used in this Episode
Keynote in PDF Format

1/25/2010

Cocoa Maker Wallpapers

I made a icon for Cocoa Maker along with some wallpapers which I'm allowing you to download. I'm going to be using this wallpaper in my podcast for now on.

Sizes
Download 640x480
Download 1024x768
Download 1280x800
Download 1920x1200

Let me know what you think,
Mr. Gecko

1/24/2010

Cocoa Maker 1 - Getting Started

James (MrGeckosMedia.com), joined by, Eduardo (MegaEduX.com), Nick, and Karl, teaches the basics of installing Xcode, setting up a project and making a "Hello, World!" command line utility.

30:16
Example code from episode.
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    NSString *name = @"World";
    if (argc>1) {
        name = [[[NSString alloc] initWithBytes:argv[1] length:strlen(argv[1]) encoding:NSUTF8StringEncoding] autorelease];
    }
    NSLog(@"Hello, %@", name);
    [pool drain];
    return 0;
}