• 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
Re: Help with Basics
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with Basics


  • Subject: Re: Help with Basics
  • From: Rounak Jain <email@hidden>
  • Date: Tue, 23 Nov 2010 22:12:11 +0530

>
> We don't know what your code looks like now.  You should re-post your *latest* code to email@hidden and state what is the problem at this time.


As Jerry pointed out, you need to learn the basics; please read up on the basics to include memory management.

The way you've now written things will cause your app to crash.  I'll leave the reason for the crash as an exercise for you to figure out.
--Ricky Sharp

My code:

#import <Cocoa/Cocoa.h>

@interface ComboscAppDelegate : NSObject <NSApplicationDelegate> {
	IBOutlet NSComboBox *countryCombo;
NSMutableDictionary *theCountries;
	NSMutableArray *myKeys;
	IBOutlet NSWindow *window;
}
@property (assign) IBOutlet NSWindow *window;
- (void)applicationWillFinishLaunching:(NSNotification *)notif;
@end



#import "ComboscAppDelegate.h"
@implementation ComboscAppDelegate

@synthesize window;
- (void)applicationWillFinishLaunching:(NSNotification *)notif {
    theCountries = [NSMutableDictionary dictionaryWithObjectsAndKeys:
					 [NSMutableArray arrayWithObjects:@"AAABBB", @"AABBB", @"AAACCC", nil], @"A",
					 [NSMutableArray arrayWithObjects:@"BBBAAA", @"BBBBBBBB", @"BBBCCC", nil], @"B",
					 [NSMutableArray arrayWithObjects:@"CCCDDD", @"CCFGGGFF", @"CCCDDDFFF", nil], @"C", nil];

	myKeys = [NSMutableArray arrayWithObjects: [theCountries allKeys], nil];
}
@end


My problem:
I am studying Cocoa from Pragmatic's Beginning Mac Programming. I have re-read the chapter of Memory Management. The basic idea that I have gathererd is:
"If you allocate an object using alloc, you need to take responsibility for releasing it when you’re done.
However, if class methods are used, then there is no need to worry about releasing objects because they are auto-released."

If someone can point me to an article that helps me understand the mistake in my code, I would be grateful._______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Help with Basics
      • From: Graham Cox <email@hidden>
    • Re: Help with Basics
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: Re: NSDebug.h where?
  • Next by Date: Re: NSDebug.h where?
  • Previous by thread: Re: Help with Basics
  • Next by thread: Re: Help with Basics
  • Index(es):
    • Date
    • Thread