<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Objective-C: Defining a Class</title>
	<atom:link href="http://MacDeveloperTips.com/objective-c/objective-c-defining-a-class.html/feed" rel="self" type="application/rss+xml" />
	<link>http://MacDeveloperTips.com/objective-c/objective-c-defining-a-class.html</link>
	<description>Tips, tools and code for iPhone and Mac developers.</description>
	<lastBuildDate>Wed, 18 Jan 2012 21:06:56 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: john</title>
		<link>http://MacDeveloperTips.com/objective-c/objective-c-defining-a-class.html/comment-page-1#comment-436</link>
		<dc:creator>john</dc:creator>
		<pubDate>Sun, 17 Aug 2008 01:25:21 +0000</pubDate>
		<guid isPermaLink="false">http://MacDeveloperTips.com/?p=209#comment-436</guid>
		<description>Comments are closed on this post. You can comment on this same post which has been moved to the iPhone Developer Tips blog: http://iphonedevelopertips.com/objective-c/defining-a-class.html</description>
		<content:encoded><![CDATA[<p>Comments are closed on this post. You can comment on this same post which has been moved to the iPhone Developer Tips blog: <a href="http://iphonedevelopertips.com/objective-c/defining-a-class.html" rel="nofollow">http://iphonedevelopertips.com/objective-c/defining-a-class.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Akit Thakur</title>
		<link>http://MacDeveloperTips.com/objective-c/objective-c-defining-a-class.html/comment-page-1#comment-429</link>
		<dc:creator>Akit Thakur</dc:creator>
		<pubDate>Wed, 13 Aug 2008 15:15:21 +0000</pubDate>
		<guid isPermaLink="false">http://MacDeveloperTips.com/?p=209#comment-429</guid>
		<description>Thanks for posting such an awesome article on objective C for intiators. I am from Java background, and currently shifted to Cocoa Objective C- Java Development in iPhone. 

With this article I have realized that Programming in Objective-C is very much similar to Java except syntax if considering import of files, getter and setter methods and their return types.

I am trying to create a directory where I want to save the Mobile no and Name of the person and want to same it in the iPhone memry. For this I am using XCode IDE. 

Can you please guide me, how can I save data in iPhone memory.

Waiting for your new article on saving data in iPhonr memory.

With regards,

Ankit Thakur
</description>
		<content:encoded><![CDATA[<p>Thanks for posting such an awesome article on objective C for intiators. I am from Java background, and currently shifted to Cocoa Objective C- Java Development in iPhone. </p>
<p>With this article I have realized that Programming in Objective-C is very much similar to Java except syntax if considering import of files, getter and setter methods and their return types.</p>
<p>I am trying to create a directory where I want to save the Mobile no and Name of the person and want to same it in the iPhone memry. For this I am using XCode IDE. </p>
<p>Can you please guide me, how can I save data in iPhone memory.</p>
<p>Waiting for your new article on saving data in iPhonr memory.</p>
<p>With regards,</p>
<p>Ankit Thakur</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad W. Taylor</title>
		<link>http://MacDeveloperTips.com/objective-c/objective-c-defining-a-class.html/comment-page-1#comment-419</link>
		<dc:creator>Chad W. Taylor</dc:creator>
		<pubDate>Sun, 03 Aug 2008 16:59:39 +0000</pubDate>
		<guid isPermaLink="false">http://MacDeveloperTips.com/?p=209#comment-419</guid>
		<description>Thanks for posting, especially the comment by Brian.  I am coming to Obj-C from .NET (mainly C#) and boy, I&#039;m having the hardest time trying to get in tune with the new syntaxes.

I always use properties (getters and setters) in C# so this definitely helps me understand how to set them up in Obj-C.  Same goes for the foreach loop in C# when looping through enumerated objects and seeing how it&#039;s done in Obj-C.

I&#039;m glad to see that Obj-C 2.0 has introduced simpler ways to set properties and iteration loops or I&#039;d have given up.  Well, probably not since I love the machine! 

Keep &#039;em coming!</description>
		<content:encoded><![CDATA[<p>Thanks for posting, especially the comment by Brian.  I am coming to Obj-C from .NET (mainly C#) and boy, I&#8217;m having the hardest time trying to get in tune with the new syntaxes.</p>
<p>I always use properties (getters and setters) in C# so this definitely helps me understand how to set them up in Obj-C.  Same goes for the foreach loop in C# when looping through enumerated objects and seeing how it&#8217;s done in Obj-C.</p>
<p>I&#8217;m glad to see that Obj-C 2.0 has introduced simpler ways to set properties and iteration loops or I&#8217;d have given up.  Well, probably not since I love the machine! </p>
<p>Keep &#8216;em coming!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stevebert</title>
		<link>http://MacDeveloperTips.com/objective-c/objective-c-defining-a-class.html/comment-page-1#comment-360</link>
		<dc:creator>stevebert</dc:creator>
		<pubDate>Mon, 23 Jun 2008 20:11:15 +0000</pubDate>
		<guid isPermaLink="false">http://MacDeveloperTips.com/?p=209#comment-360</guid>
		<description>Great article!  I would also recommend that folks new to Objective-C (folks familiar with it, too!) take a look at 2 new features of Objective-C 2.0 introduced in 10.5/Leopard: properties and fast enumeration.

Using ObjC2 properties forgoes the need to write getter-setter methods entirely:

@interface SomeClass : NSObject
{
    NSString *_str;
    NSDate *_date;
    int _x
}
@property(retain, readwrite) NSString *str;
@property(retain, readwrite) NSDate *date;
@property(assign, readwrite) int x;
:

@implementation SomeClass
@synthesize str = _str;
@synthesize date = _date;
@synthesize x = _x;

In this case the @property declaration, combined with the @synthesize, will automatically generate getter/setter methods for each instance variable -- a real time-saver when your class declares a 20 variables (or even if you only declare 1).  Since most getter/setter implementations follow the same code template, this can be a nice time saver and leaves the code less cluttered and easier to maintain.

Properties declared with (retain, ...) will automatically call [NSObject retain] when a new value is assigned to the instance variable via the synthesized setter, as well as [NSObject release] for the previously assigned object.  The &quot;assign&quot; modifier tells the compiler to generate a simple assignment, useful for non-Cocoa variable types, or NSObject references which do not need to be retained.  Variables can alternately be declared &quot;readonly&quot;, which generates compiler errors if the code attempts to make an assignment.  These are the most common modifiers -- the Objective-C 2.0 guide defines others for special cases.

Concurrent with the new property declarations is the change to &quot;.&quot; notation for accessing getter/setting methods.

SomeClass *anInst = [[[SomeClass alloc] init] autorelease];
anInst.str = @&quot;Hello, world!&quot;; // retained
anInst.date = [NSDate date]; // retained
anInst.x = 5;  // assigned

The underscore (&quot;_&quot;) notation in the instance variable declarations are optional, but a useful way to distinguish direct variable references from getter/setter references in your code.

@implementation SomeClass
:
- (void) setDefaultX
{
    _x = 5; // direct assignment
}

Once you get used to the property syntax, the older form of Objective-C feels clunky.

Fast enumeration is a newer way to iterate through NSArray collections.  The traditional way of writing iteration loops is familiar to most Cocoa programmers:

NSArray *aList = [myClass getListOfObjects];
NSEnumerator *anEnum = [aList objectEnumerator];
NSString *aStr = nil;
while (nil != (aStr = [anEnum nextObject])) {...}

With fast enumeration, the same code appears as follows:

NSArray *aList = [myClass getListOfObjects];
for (NSString *aStr in aList) {...}

Not only is it less code, which is always a good thing, but the fast enumeration form allows the compiler to make optimizations in the loop interation that can be several times faster than the older NSEnumerator-based loops.

I find these new features of Objective-C 2.0 to be very handy in writing more compact, readable code, which lets me concentrate more on the logic of my own application, rather than the syntactic overhead of writing classes.

Enjoy!</description>
		<content:encoded><![CDATA[<p>Great article!  I would also recommend that folks new to Objective-C (folks familiar with it, too!) take a look at 2 new features of Objective-C 2.0 introduced in 10.5/Leopard: properties and fast enumeration.</p>
<p>Using ObjC2 properties forgoes the need to write getter-setter methods entirely:</p>
<p>@interface SomeClass : NSObject<br />
{<br />
    NSString *_str;<br />
    NSDate *_date;<br />
    int _x<br />
}<br />
@property(retain, readwrite) NSString *str;<br />
@property(retain, readwrite) NSDate *date;<br />
@property(assign, readwrite) int x;<br />
:</p>
<p>@implementation SomeClass<br />
@synthesize str = _str;<br />
@synthesize date = _date;<br />
@synthesize x = _x;</p>
<p>In this case the @property declaration, combined with the @synthesize, will automatically generate getter/setter methods for each instance variable &#8212; a real time-saver when your class declares a 20 variables (or even if you only declare 1).  Since most getter/setter implementations follow the same code template, this can be a nice time saver and leaves the code less cluttered and easier to maintain.</p>
<p>Properties declared with (retain, &#8230;) will automatically call [NSObject retain] when a new value is assigned to the instance variable via the synthesized setter, as well as [NSObject release] for the previously assigned object.  The &#8220;assign&#8221; modifier tells the compiler to generate a simple assignment, useful for non-Cocoa variable types, or NSObject references which do not need to be retained.  Variables can alternately be declared &#8220;readonly&#8221;, which generates compiler errors if the code attempts to make an assignment.  These are the most common modifiers &#8212; the Objective-C 2.0 guide defines others for special cases.</p>
<p>Concurrent with the new property declarations is the change to &#8220;.&#8221; notation for accessing getter/setting methods.</p>
<p>SomeClass *anInst = [[[SomeClass alloc] init] autorelease];<br />
anInst.str = @&#8221;Hello, world!&#8221;; // retained<br />
anInst.date = [NSDate date]; // retained<br />
anInst.x = 5;  // assigned</p>
<p>The underscore (&#8220;_&#8221;) notation in the instance variable declarations are optional, but a useful way to distinguish direct variable references from getter/setter references in your code.</p>
<p>@implementation SomeClass<br />
:<br />
- (void) setDefaultX<br />
{<br />
    _x = 5; // direct assignment<br />
}</p>
<p>Once you get used to the property syntax, the older form of Objective-C feels clunky.</p>
<p>Fast enumeration is a newer way to iterate through NSArray collections.  The traditional way of writing iteration loops is familiar to most Cocoa programmers:</p>
<p>NSArray *aList = [myClass getListOfObjects];<br />
NSEnumerator *anEnum = [aList objectEnumerator];<br />
NSString *aStr = nil;<br />
while (nil != (aStr = [anEnum nextObject])) {&#8230;}</p>
<p>With fast enumeration, the same code appears as follows:</p>
<p>NSArray *aList = [myClass getListOfObjects];<br />
for (NSString *aStr in aList) {&#8230;}</p>
<p>Not only is it less code, which is always a good thing, but the fast enumeration form allows the compiler to make optimizations in the loop interation that can be several times faster than the older NSEnumerator-based loops.</p>
<p>I find these new features of Objective-C 2.0 to be very handy in writing more compact, readable code, which lets me concentrate more on the logic of my own application, rather than the syntactic overhead of writing classes.</p>
<p>Enjoy!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://MacDeveloperTips.com/objective-c/objective-c-defining-a-class.html/comment-page-1#comment-359</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Mon, 23 Jun 2008 18:11:54 +0000</pubDate>
		<guid isPermaLink="false">http://MacDeveloperTips.com/?p=209#comment-359</guid>
		<description>Thanks, keep these up!</description>
		<content:encoded><![CDATA[<p>Thanks, keep these up!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

