Assigning new instance of a class to an object that had an instance of the class

Discussion in 'iOS Programming' started by moonman239, Oct 10, 2013.

  1. moonman239 macrumors 68000

    Mar 27, 2009
    I posted in another thread about how I am unable to reinitialize a voice recognizer. I might have figured out why. I'm thinking that I need to know how to assign a new instance to a variable that previously had one. I'm using ARC, so I can't use dealloc, and setting the variable to nil does not work either.
  2. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    If you weren't using ARC, you'd use release, not dealloc.

    Write a test case.

    Instead of SKRecognizer, make instances of a class like NSMutableArray. That's a class with well-known and well-described behavior. You can write all the necessary tests, NSLogs, etc. using NSMutableArray (or indeed any class with well-known creation behavior). This will show you how a well-known class works. Then you can change one line to instantiate SKRecognizer, and compare the new results with the results from NSMutableArray.

    Post actual code.

    You mention using variables, and using ARC, but ARC has no special meaning for certain kinds of variables. The kind of variable makes a big difference: is it static? Global? Instance variable? Local variable? We can guess, or we might look at your other thread, where you may or may not have posted real code. Or you can write a test case, run it, then post the actual code with any questions you might have.

    If you encounter a problem when writing your test case, post the code you've written to that point, and ask a specific question about it.
  3. moonman239 thread starter macrumors 68000

    Mar 27, 2009
    I have evidence that shows that the code was fine this whole time.
  4. xStep, Oct 11, 2013
    Last edited: Oct 13, 2013

    xStep macrumors 68000

    Jan 28, 2003
    Less lost in L.A.
    No such evidence exists here.

Share This Page