• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
That Cocoa Book...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

That Cocoa Book...


  • Subject: That Cocoa Book...
  • From: "Michael F Brinkman" <email@hidden>
  • Date: Mon, 31 Dec 2001 13:23:03 -0500 (EST)

I just bought the "Cocoa Programming for Mac OS X", and went to the web page to
look for a solution to the challenge problem on page 102. There isn't a
solution to the challenge question posted.

I made an application called "LetterCounter", which works, but I wanted to
compare my solution to the book's. I'm not really sure what I was supposed to
do with allocating and deallocating memory, or if I'm even supposed to do
something.

This is what I put in my Controller.h file:

#import <Cocoa/Cocoa.h>

@interface Controller : NSObject
{
IBOutlet id inputField;
IBOutlet id outputField;
NSString *myString;
int myCount;
}
- (IBAction)countButton:(id)sender;
@end

This is what I put in my Controller.m file:

#import "Controller.h"

@implementation Controller

- (void)awakeFromNib
{
[outputField setStringValue: @"???"];
}

- (IBAction)countButton:(id)sender
{
myString = [inputField stringValue];
myCount = [myString length];
[outputField setStringValue: [NSString stringWithFormat: @"%@ contains %d
letters", myString, myCount]];
}
@end

Is there something I'm supposed to do in order to handle memory allocation and
destroying myString?

Over all, I've enjoyed the book (I got it yesterday and have gone through the
first 100 pages), but I wish the web site had solutions to the challenge
questions. You think it would, since I just dropped $45 on it and it didn't
come with a CD. Am I being unreasonable, or have I simply overlooked something?

Anyway, sorry for the mini-rant, any help on a solution to the programming
problem or the web page problem would be greatly appreciated!

Happy New Year!
Mike Brinkman


  • Follow-Ups:
    • Re: That Cocoa Book...
      • From: John Nestor <email@hidden>
  • Prev by Date: Sizing view in NSScrollView
  • Next by Date: Re: Cocoa questions
  • Previous by thread: Sizing view in NSScrollView
  • Next by thread: Re: That Cocoa Book...
  • Index(es):
    • Date
    • Thread