Hi everyone, should hopefully be an easy question (teaching myself Objective C as I go).
I would like to send a method to an object (Cell) which returns a different object (Waste), and then deletes the reciever (Cell). Here is what I'm looking at so far:
I've put the two issues that come up behind the comments so you know where the problems are, but they're:
ARC Semantic Issue: No known class method for selector 'alloc'
and
ARC Semantic Issue: Cannot assign to 'self' outside of a method in the init family
Could someone tell me why this is happening and how to fix it? I had thought it was straightforward to do:
Class *newInstance = [[Class alloc] init];
and that this could be done inside a method so you can return the instance. And I had read that self = nil; was the normal way for releasing objects with ARC.
Thank you for any help!
I would like to send a method to an object (Cell) which returns a different object (Waste), and then deletes the reciever (Cell). Here is what I'm looking at so far:
Code:
#import "Cell.h"
#import "Waste.h"
@implementation Cell
@synthesize.......
other methods.....
- (Waste *) die // Send a method to an instance of class "Cell", causing a new object of class "Waste" to be made, then causing the Cell instance to "die"
{
Waste *newWaste = [[Waste alloc] init]; // Create a new object, "newWaste", of class Waste ARC Semantic Issue: No known class method for selector 'alloc'
newWaste.wasteEnergy = (0.1 * cellEnergy); // Set the energy of "newWa" to 10% what the Cell's energy is
newWaste.wasteXCoordinate = cellXCoordinate; // Set the X coordinate of "r" to the Cell's X coordinate
newWaste.wasteYCoordinate = cellYCoordinate; // Set the Y coordinate of "r" to the Cell's Y coordinate
newWaste.wasteExcreted = NO; // Variable saying if the Waste is to be excreted set to "NO"
return newWaste; // Return the new waste object
self = nil; // Have the Cell "die" ARC Semantic Issue: Cannot assign to 'self' outside of a method in the init family
};
I've put the two issues that come up behind the comments so you know where the problems are, but they're:
ARC Semantic Issue: No known class method for selector 'alloc'
and
ARC Semantic Issue: Cannot assign to 'self' outside of a method in the init family
Could someone tell me why this is happening and how to fix it? I had thought it was straightforward to do:
Class *newInstance = [[Class alloc] init];
and that this could be done inside a method so you can return the instance. And I had read that self = nil; was the normal way for releasing objects with ARC.
Thank you for any help!