Amazon.com Widgets class method +(int) count
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 23, 2013, 09:33:13 PM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Programming in Objective-C, 4th edition
| |-+  Chapter 10
| | |-+  class method +(int) count
Pages: [1]   Go Down
Print
Author Topic: class method +(int) count  (Read 501 times)
donjeong
Newbie
*
Posts: 4






« on: July 20, 2012, 04:55:20 PM »

I know allocF must be class method because it returns [Fraction alloc].
But count can be a instance method, right?
Logged
fujilla
Global Moderator
Sr. Member
*****
Posts: 270


WWW




« Reply #1 on: July 21, 2012, 02:43:26 AM »

The count: method, needs to be a class method, or it would not work correctly.

What it is doing is generating a counter which will be added to, each time an instance of the Fraction class is created.

Therefore, if it was an instance method, then the result would only be 1 each time.

Nick
http://myfirstiphoneapp.co.uk
http://easyintervalsapp.co.uk
Logged
donjeong
Newbie
*
Posts: 4






« Reply #2 on: July 21, 2012, 11:21:48 AM »

I got it!
Thanks Nick.
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.