Re: NSMutableCopy Issue - New to Cocoa and Objective-C
Re: NSMutableCopy Issue - New to Cocoa and Objective-C
- Subject: Re: NSMutableCopy Issue - New to Cocoa and Objective-C
- From: Andrew Filipowski <email@hidden>
- Date: Tue, 26 Jul 2005 07:25:04 -0500
Nevermind I figured it out, for some reason in my weeks method (the
one that creates the copy) if I change the mutableCopy to copy it
works as expected though not sure why.
I am sure I'll be on this mailing list with other questions in the
future. I have only sub'd to it for about 24 hours and it looks like
a great resource. Especially when the pros help out the newbies like me.
My hope is one day to repay all of you by being able to answer
questions myself
Andrew
On Jul 26, 2005, at 7:16 AM, Andrew Filipowski wrote:
Just to further clarify I tried something else that I read in
"Programming in Objective-C" by Stephen Kochan.
I added the following to my Player class based on his example in
the book for a fraction found on page 422.
-(Player *) copyWithZone: (NSZone *)zone
{
Player *newPlayer = [[Player allocWithZone: zone] init];
[newPlayer setPlayerName:playerName];
[newPlayer setPlayerPosition:playerPosition];
[newPlayer setPlayerTeam:playerTeam];
[newPlayer setPlayerOpponant:playerOpponant];
[newPlayer setPlayerOnBye:playerOnBye];
[newPlayer setPlayerAtHome:playerAtHome];
[newPlayer setPlayerWeeksPlayed:playerWeeksPlayed];
[newPlayer setPlayerShouldStart:playerShouldStart];
[newPlayer setPlayerIsAStarter:playerIsAStarter];
[newPlayer setPlayerTotalScore:playerTotalScore];
[newPlayer setPlayerAverageScore:playerAverageScore];
[newPlayer setPlayerScoreForLastWeek:playerScoreForLastWeek];
[newPlayer createRanks];
[newPlayer createProjections];
return newPlayer;
}
This did not work either I am still getting the same error. I have
all of those methods defined as well in the class.
Thanks again.
On Jul 26, 2005, at 6:39 AM, Andrew Filipowski wrote:
I am having a little bit of an issue figuring out why I can't make
a mutable copy of one of my objects. I learn allot better by doing
than reading so I bought a couple of books on Objective-C and
Cocoa and have started writing an app that I have wanted to have
for years. Here is the basics. I have an array of leagues, these
leagues have weeks and each week has an array of players. From
week to week the players may or may not be the same (for the most
part they are with the subtraction and addition of a new member).
When the user clicks on the add new week button, I add a week and
want to copy the players to the new week. I originally just copied
the array that they were in thinking that it was a deep copy I was
wrong. So I created a new method in my weeks object that creates
iterates through an array it is passed (the previous weeks array)
and copies the player objects in side. Here is the code for that
method:
-(void)createPlayersFromPreviousWeek:(NSMutableArray *)aPlayersArray
{
players = [[NSMutableArray alloc] init];
int n;
for (n = 0; n < [aPlayersArray count]; n++)
{
[players insertObject:[[aPlayersArray objectAtIndex:n]
mutableCopy] atIndex:n];
}
}
I have added the following to my Player.h file as well:
@interface Player : NSObject <NSCoding, NSCopying, NSMutableCopying>
This is the error that I receive when I run my app:
*** NSRunLoop ignoring exception '*** -[Player copyWithZone:]:
selector not recognized [self = 0x3c4910]' that raised during
posting of delayed perform with target 3d5fe0 and selector
'invokeWithTarget:'
Any help would be much appreciated there is one other thing that
is giving me problems right now but I am trying to tackle one
issue at a time.
Andrew
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden