• 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: mutating method sent to immutable object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: mutating method sent to immutable object


  • Subject: RE: mutating method sent to immutable object
  • From: "Jonathan E. Jackel" <email@hidden>
  • Date: Fri, 2 May 2003 14:43:12 -0400

Have you stepped through the code in the debugger to see which line is
causing the problem?

Jonathan

> -----Original Message-----
> From: email@hidden
> [mailto:email@hidden]On Behalf Of Hasan Diwan
> Sent: Friday, May 02, 2003 2:09 PM
> To: Cocoa
> Subject: mutating method sent to immutable object
>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I'm writing a small program to keep track of my wine collection. The
> entire source is below, and it's giving me the above error. Needless to
> say, I can't figure out what's wrong.
> @implementation WineX
> - - (id)init {
> if (self = [super init]) {
> records = [[NSMutableArray arrayWithArray:[[NSUserDefaults
> standardUserDefaults] arrayForKey:@"records"]] mutableCopy];
> [dataDisplay setDataSource:self];
> [dataDisplay setDelegate:self];
> [dataDisplay setDoubleAction:@selector(doubleClick:)];
> if (nil == records) {
> records = [[NSMutableArray array] retain];
> }
> [self newRecord:self];
> }
> return self;
> }
>
> - - (void)createNewRecord {
> NSMutableDictionary *d = [[NSMutableDictionary alloc] init];
> [records addObject:d];
> [d release];
> }
>
> - - (void)applicationWillTerminate:(NSNotification *)n {
> [[NSUserDefaults standardUserDefaults] setObject:records
> forKey:@"records"];
> }
>
> - - (void)dealloc {
> [[NSUserDefaults standardUserDefaults] synchronize];
> [records release];
> [super dealloc];
> }
>
> - - (id)tableView:(NSTableView *)aTableView
> objectValueForTableColumn:(NSTableColumn *)aTableColumn
> row:(int)rowIndex
> {
> id theRecord, theValue;
>
> theRecord = [records objectAtIndex:rowIndex];
> theValue = [theRecord objectForKey:[aTableColumn identifier]];
> return theValue;
> }
>
> - - (void)tableView:(NSTableView *)aTableView
> setObjectValue:anObject
> forTableColumn:(NSTableColumn *)aTableColumn
> row:(int)rowIndex
> {
> id theRecord;
>
> NSLog(@"%@", records);
> theRecord = [records objectAtIndex:rowIndex];
> [theRecord setObject:anObject forKey:[aTableColumn identifier]];
> return;
> }
> - - (int)numberOfRowsInTableView:(NSTableView *)aTableView
> {
> return [records count];
> }
>
> - - (IBAction)newRecord:(id)sender {
> [self createNewRecord];
> [dataDisplay reloadData];
> }
>
> @end
> @implementation NSMutableDictionary (UnableToSetNilForKey)
> - - (BOOL)unableToSetNilForKey:(NSString *)k {
> if ([k isEqualToString:@"Score"]) {
> [self setObject:[NSNumber numberWithInt:0] forKey:k];
> return YES;
> }
> return NO;
> }
> @end
> Hasan Diwan {http://ibn.com/~hdiwan}
> OpenPGP Fingerprint: 275D 0E84 550C D92A 4A56 732C 8528 2579 E6E9 4842
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (Darwin)
>
> iD8DBQE+srRDhSgleebpSEIRAtIHAJ4hNfYENG9NY7MMFyKLb0QVvnK9UgCgjFzT
> IAQYJNSWZj3RChiqEvsQG64=
> =/0mh
> -----END PGP SIGNATURE-----
> _______________________________________________
> cocoa-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >mutating method sent to immutable object (From: Hasan Diwan <email@hidden>)

  • Prev by Date: mutating method sent to immutable object
  • Next by Date: How to call AS method from Cocoa ?
  • Previous by thread: mutating method sent to immutable object
  • Next by thread: Re: mutating method sent to immutable object
  • Index(es):
    • Date
    • Thread