Skip to content
Cocoa Maker 2 - Syntax episode artwork

EPISODE · Feb 1, 2010

Cocoa Maker 2 - Syntax

from Cocoa Maker · host Mr. Gecko

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

Episode metadata supplied by the publisher feed · Published Feb 1, 2010

Embed this episode

Ready to play

Cocoa Maker 2 - Syntax

0:00 0:00

No transcript for this episode yet

We transcribe on demand. Request one and we'll notify you when it's ready — usually under 10 minutes.

No similar episodes found.

AI, Government, and the Future Corner Alliance Welcome to AI, Government, and the Future, a podcast by Corner Alliance. We explore the intersection of artificial intelligence, government, and the future. Join us as we dive into the latest AI advancements, government policies, and innovative strategies to shape the future of our society. Whether you're a policy maker, venture capitalist, academic, or industry leader, this podcast will provide valuable insights and thought-provoking discussions to help you navigate the evolving landscape of AI and its impact on government. Tune in to AI, Government, and the Future to stay ahead in this transformative era. The Bootloader Paul Cutler and Tod Kurt A monthly podcast loading you up with news, project updates and product talk from the CircuitPython and maker communities. Hosted by Tod Kurt and Paul Cutler. Hack Learning Mark Barnes Learn quick and easy ways to improve education, leadership, and parenting: How to replace traditional homework; how to improve leadership; how to integrate new technology; how to assess for learning; how to eliminate useless meetings; how to engage even the most reluctant learners; how to inspire a lifelong love of reading; how to combine writing with the maker space; how to take learning mobile; how to improve social media strategies. Teacher/author/global influencer Mark Barnes, creator of the Bestselling Hack Learning Book Series, explains precisely what's wrong with education and what you can do about it, tomorrow; because you don't need a 5-year plan. Learn more at http://10publications.com.

Frequently Asked Questions

When was this Cocoa Maker episode published?

This episode was published on February 1, 2010.

Can I download this Cocoa Maker episode?

Yes. Use the download control on the episode player to save the publisher-provided media file.
URL copied to clipboard!