Amazon.com Widgets Ex 15.10 my solution
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 29, 2014, 12:14:52 AM
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
|-+ Old Stuff
| |-+ Answers to Exercises
| | |-+ Chapter 15
| | | |-+ Ex 15.10 my solution
Pages: [1] Go Down
Print
Author Topic: Ex 15.10 my solution (Read 612 times)
iseeumhmm
Newbie
*
Posts: 7






on: November 30, 2011, 10:28:56 AM

Code: (Objective-C)
//
//  main.m
//  Ex15
//
//  Created by Richard Heffren on 11-11-30.
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#define intig(x) [NSNumber numberWithInt:(x)]

int main (int argc, const char * argv[])
{
    NSAutoreleasePool   *pool = [[NSAutoreleasePool alloc] init];
   
    NSArray             *nums = [[NSArray alloc] initWithObjects:
                                 intig(1), intig(1), intig(1), intig(2), intig(3), intig(3), nil];

    NSCountedSet        *freq = [[NSCountedSet alloc] initWithArray: nums];
    NSEnumerator        *enumerator = [freq objectEnumerator];
    id object;
   
    while (object = [enumerator nextObject]) {
        NSLog(@"%@ was added %lu times", object, [freq countForObject: object]);
    }
   
    [nums release];
    [freq release];
    [pool drain];
    return 0;
}

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.