Some crash.

  • Greetings,

    I don't quite know how to explain this.. :) so please excuse me if I'm
    not very precise.

    In my application controller i have an object "statement" that
    contains an array of "transactions" called transactions.
    here is the structure of transaction.
    @interface OFXTransaction : NSObject {
    NSString *transactionType;
    NSDate  *datePosted;
    double  transactionAmount;
    NSString *uniqueID;
    NSString *displayName;
    NSString *memo;
    }
    @property (readwrite, copy)    NSString    *transactionType;
    @property (readwrite, copy)    NSDate        *datePosted;
    @property (readwrite, assign)    double        transactionAmount;
    @property (readwrite, copy)    NSString    *uniqueID;
    @property (readwrite, copy)    NSString    *displayName;
    @property (readwrite, copy)    NSString    *memo;

    - (void) setStringDatePosted: (NSString *)dateString;
    @end

    In interface builder I've set my appController as the Datasource of
    the tableview, implemented the methods for the table to load data.
    the array controller is bound to "statement.transactions" as the
    keypath.
    the table view is bound to the array controller, and each column is
    bound to a field in the transaction class.

    everything seems to be working good, except when i have a value in the
    transactionAmount property.

    can anyone enlighten me as for why it breaks ? please :)

    I get this error.
    2008-08-02 13:52:23.411 OFXImport[27702:10b] *** -[OFXTransaction
    copyWithZone:]: unrecognized selector sent to instance 0xf4fb80
    2008-08-02 13:52:23.412 OFXImport[27702:10b] An uncaught exception was
    raised
    2008-08-02 13:52:23.413 OFXImport[27702:10b] *** -[OFXTransaction
    copyWithZone:]: unrecognized selector sent to instance 0xf4fb80
    2008-08-02 13:52:23.413 OFXImport[27702:10b] *** Terminating app due
    to uncaught exception 'NSInvalidArgumentException', reason: '*** -
    [OFXTransaction copyWithZone:]: unrecognized selector sent to instance
    0xf4fb80'
    2008-08-02 13:52:23.414 OFXImport[27702:10b] Stack: (
        2417631563,
        2425491707,
        2417660746,
        2417654092,
        2417654290,
        2519207652,
        2519290634,
        2519290371,
        2519978356,
        2519977828,
        2519975066,
        2519603468,
        2519598064,
        2520189316,
        2520183931,
        2520184850,
        2520184850,
        2520184850,
        2520184850,
        2520178129,
        2520176403,
        2520162871,
        2519379087,
        2519377981,
        2520146833,
        2520145384,
        2520350309,
        2519174399,
        2519133714,
        2519132020,
        2519131063,
        2519130869,
        2519130020
    )
  • maybe a retain problem

    On Sat, Aug 2, 2008 at 11:03 AM, Sandro Noel <sandro.noel...> wrote:
    > Greetings,
    >
    > I don't quite know how to explain this.. :) so please excuse me if I'm not
    > very precise.
    >
    > In my application controller i have an object "statement" that contains an
    > array of "transactions" called transactions.
    > here is the structure of transaction.
    > @interface OFXTransaction : NSObject {
    > NSString        *transactionType;
    > NSDate          *datePosted;
    > double          transactionAmount;
    > NSString        *uniqueID;
    > NSString        *displayName;
    > NSString        *memo;
    > }
    > @property (readwrite, copy)    NSString        *transactionType;
    > @property (readwrite, copy)    NSDate          *datePosted;
    > @property (readwrite, assign)  double          transactionAmount;
    > @property (readwrite, copy)    NSString        *uniqueID;
    > @property (readwrite, copy)    NSString        *displayName;
    > @property (readwrite, copy)    NSString        *memo;
    >
    > - (void) setStringDatePosted: (NSString *)dateString;
    > @end
    >
    > In interface builder I've set my appController as the Datasource of the
    > tableview, implemented the methods for the table to load data.
    > the array controller is bound to "statement.transactions" as the keypath.
    > the table view is bound to the array controller, and each column is bound to
    > a field in the transaction class.
    >
    > everything seems to be working good, except when i have a value in the
    > transactionAmount property.
    >
    > can anyone enlighten me as for why it breaks ? please :)
    >
    > I get this error.
    > 2008-08-02 13:52:23.411 OFXImport[27702:10b] *** -[OFXTransaction
    > copyWithZone:]: unrecognized selector sent to instance 0xf4fb80
    > 2008-08-02 13:52:23.412 OFXImport[27702:10b] An uncaught exception was
    > raised
    > 2008-08-02 13:52:23.413 OFXImport[27702:10b] *** -[OFXTransaction
    > copyWithZone:]: unrecognized selector sent to instance 0xf4fb80
    > 2008-08-02 13:52:23.413 OFXImport[27702:10b] *** Terminating app due to
    > uncaught exception 'NSInvalidArgumentException', reason: '***
    > -[OFXTransaction copyWithZone:]: unrecognized selector sent to instance
    > 0xf4fb80'
    > 2008-08-02 13:52:23.414 OFXImport[27702:10b] Stack: (
    > 2417631563,
    > 2425491707,
    > 2417660746,
    > 2417654092,
    > 2417654290,
    > 2519207652,
    > 2519290634,
    > 2519290371,
    > 2519978356,
    > 2519977828,
    > 2519975066,
    > 2519603468,
    > 2519598064,
    > 2520189316,
    > 2520183931,
    > 2520184850,
    > 2520184850,
    > 2520184850,
    > 2520184850,
    > 2520178129,
    > 2520176403,
    > 2520162871,
    > 2519379087,
    > 2519377981,
    > 2520146833,
    > 2520145384,
    > 2520350309,
    > 2519174399,
    > 2519133714,
    > 2519132020,
    > 2519131063,
    > 2519130869,
    > 2519130020
    > )
    >

    --
    -mmw
  • I've tried enumerating the objects to the log, with a button on the
    interface.
    and they are all still in memory, they are not being released.
    all the items report.

    anything else ?

    Sandro.

    On 2-Aug-08, at 2:06 PM, mm w wrote:

    > maybe a retain problem
    >
    > On Sat, Aug 2, 2008 at 11:03 AM, Sandro Noel <sandro.noel...>
    > wrote:
    >> Greetings,
    >>
    >> I don't quite know how to explain this.. :) so please excuse me if
    >> I'm not
    >> very precise.
    >>
    >> In my application controller i have an object "statement" that
    >> contains an
    >> array of "transactions" called transactions.
    >> here is the structure of transaction.
    >> @interface OFXTransaction : NSObject {
    >> NSString        *transactionType;
    >> NSDate          *datePosted;
    >> double          transactionAmount;
    >> NSString        *uniqueID;
    >> NSString        *displayName;
    >> NSString        *memo;
    >> }
    >> @property (readwrite, copy)    NSString        *transactionType;
    >> @property (readwrite, copy)    NSDate          *datePosted;
    >> @property (readwrite, assign)  double          transactionAmount;
    >> @property (readwrite, copy)    NSString        *uniqueID;
    >> @property (readwrite, copy)    NSString        *displayName;
    >> @property (readwrite, copy)    NSString        *memo;
    >>
    >> - (void) setStringDatePosted: (NSString *)dateString;
    >> @end
    >>
    >> In interface builder I've set my appController as the Datasource of
    >> the
    >> tableview, implemented the methods for the table to load data.
    >> the array controller is bound to "statement.transactions" as the
    >> keypath.
    >> the table view is bound to the array controller, and each column is
    >> bound to
    >> a field in the transaction class.
    >>
    >> everything seems to be working good, except when i have a value in
    >> the
    >> transactionAmount property.
    >>
    >> can anyone enlighten me as for why it breaks ? please :)
    >>
    >> I get this error.
    >> 2008-08-02 13:52:23.411 OFXImport[27702:10b] *** -[OFXTransaction
    >> copyWithZone:]: unrecognized selector sent to instance 0xf4fb80
    >> 2008-08-02 13:52:23.412 OFXImport[27702:10b] An uncaught exception
    >> was
    >> raised
    >> 2008-08-02 13:52:23.413 OFXImport[27702:10b] *** -[OFXTransaction
    >> copyWithZone:]: unrecognized selector sent to instance 0xf4fb80
    >> 2008-08-02 13:52:23.413 OFXImport[27702:10b] *** Terminating app
    >> due to
    >> uncaught exception 'NSInvalidArgumentException', reason: '***
    >> -[OFXTransaction copyWithZone:]: unrecognized selector sent to
    >> instance
    >> 0xf4fb80'
    >> 2008-08-02 13:52:23.414 OFXImport[27702:10b] Stack: (
    >> 2417631563,
    >> 2425491707,
    >> 2417660746,
    >> 2417654092,
    >> 2417654290,
    >> 2519207652,
    >> 2519290634,
    >> 2519290371,
    >> 2519978356,
    >> 2519977828,
    >> 2519975066,
    >> 2519603468,
    >> 2519598064,
    >> 2520189316,
    >> 2520183931,
    >> 2520184850,
    >> 2520184850,
    >> 2520184850,
    >> 2520184850,
    >> 2520178129,
    >> 2520176403,
    >> 2520162871,
    >> 2519379087,
    >> 2519377981,
    >> 2520146833,
    >> 2520145384,
    >> 2520350309,
    >> 2519174399,
    >> 2519133714,
    >> 2519132020,
    >> 2519131063,
    >> 2519130869,
    >> 2519130020
    >> )
    >>
    >
    >
    >
    > --
    > -mmw
  • On Aug 2, 2008, at 11:03 AM, Sandro Noel wrote:

    > Greetings,
    >
    > I don't quite know how to explain this.. :) so please excuse me if
    > I'm not very precise.

    [...]

    > 2008-08-02 13:52:23.411 OFXImport[27702:10b] *** -[OFXTransaction
    > copyWithZone:]: unrecognized selector sent to instance 0xf4fb80

    Have you used the debugger to set a breakpoint on objc_exception_throw
    and see what's trying to copy your object?

    --
    Adam
  • Hi let me suggest you the good question:
    what's actually triggering the -copyWithZone call?

    On Sat, Aug 2, 2008 at 12:32 PM, Sandro Noel <sandro.noel...> wrote:
    > I've tried enumerating the objects to the log, with a button on the
    > interface.
    > and they are all still in memory, they are not being released.
    > all the items report.
    >
    > anything else ?
    >
    > Sandro.
    >
    >
    > On 2-Aug-08, at 2:06 PM, mm w wrote:
    >
    >> maybe a retain problem
    >>
    >> On Sat, Aug 2, 2008 at 11:03 AM, Sandro Noel <sandro.noel...> wrote:
    >>>
    >>> Greetings,
    >>>
    >>> I don't quite know how to explain this.. :) so please excuse me if I'm
    >>> not
    >>> very precise.
    >>>
    >>> In my application controller i have an object "statement" that contains
    >>> an
    >>> array of "transactions" called transactions.
    >>> here is the structure of transaction.
    >>> @interface OFXTransaction : NSObject {
    >>> NSString        *transactionType;
    >>> NSDate          *datePosted;
    >>> double          transactionAmount;
    >>> NSString        *uniqueID;
    >>> NSString        *displayName;
    >>> NSString        *memo;
    >>> }
    >>> @property (readwrite, copy)    NSString        *transactionType;
    >>> @property (readwrite, copy)    NSDate          *datePosted;
    >>> @property (readwrite, assign)  double          transactionAmount;
    >>> @property (readwrite, copy)    NSString        *uniqueID;
    >>> @property (readwrite, copy)    NSString        *displayName;
    >>> @property (readwrite, copy)    NSString        *memo;
    >>>
    >>> - (void) setStringDatePosted: (NSString *)dateString;
    >>> @end
    >>>
    >>> In interface builder I've set my appController as the Datasource of the
    >>> tableview, implemented the methods for the table to load data.
    >>> the array controller is bound to "statement.transactions" as the keypath.
    >>> the table view is bound to the array controller, and each column is bound
    >>> to
    >>> a field in the transaction class.
    >>>
    >>> everything seems to be working good, except when i have a value in the
    >>> transactionAmount property.
    >>>
    >>> can anyone enlighten me as for why it breaks ? please :)
    >>>
    >>> I get this error.
    >>> 2008-08-02 13:52:23.411 OFXImport[27702:10b] *** -[OFXTransaction
    >>> copyWithZone:]: unrecognized selector sent to instance 0xf4fb80
    >>> 2008-08-02 13:52:23.412 OFXImport[27702:10b] An uncaught exception was
    >>> raised
    >>> 2008-08-02 13:52:23.413 OFXImport[27702:10b] *** -[OFXTransaction
    >>> copyWithZone:]: unrecognized selector sent to instance 0xf4fb80
    >>> 2008-08-02 13:52:23.413 OFXImport[27702:10b] *** Terminating app due to
    >>> uncaught exception 'NSInvalidArgumentException', reason: '***
    >>> -[OFXTransaction copyWithZone:]: unrecognized selector sent to instance
    >>> 0xf4fb80'
    >>> 2008-08-02 13:52:23.414 OFXImport[27702:10b] Stack: (
    >>> 2417631563,
    >>> 2425491707,
    >>> 2417660746,
    >>> 2417654092,
    >>> 2417654290,
    >>> 2519207652,
    >>> 2519290634,
    >>> 2519290371,
    >>> 2519978356,
    >>> 2519977828,
    >>> 2519975066,
    >>> 2519603468,
    >>> 2519598064,
    >>> 2520189316,
    >>> 2520183931,
    >>> 2520184850,
    >>> 2520184850,
    >>> 2520184850,
    >>> 2520184850,
    >>> 2520178129,
    >>> 2520176403,
    >>> 2520162871,
    >>> 2519379087,
    >>> 2519377981,
    >>> 2520146833,
    >>> 2520145384,
    >>> 2520350309,
    >>> 2519174399,
    >>> 2519133714,
    >>> 2519132020,
    >>> 2519131063,
    >>> 2519130869,
    >>> 2519130020
    >>> )
    >>>
    >>
    >>
    >>
    >> --
    >> -mmw
    >
    >

    --
    -mmw
  • Thanks guy's.

    I figured it out, i'm using an array controller and my dataSource for
    the table view was set to my application controller.
    instead of being set to the array controller.

    the matter was resolved...

    Sandro.

    On 2-Aug-08, at 3:43 PM, Adam R. Maxwell wrote:

    >
    > On Aug 2, 2008, at 11:03 AM, Sandro Noel wrote:
    >
    >> Greetings,
    >>
    >> I don't quite know how to explain this.. :) so please excuse me if
    >> I'm not very precise.
    >
    > [...]
    >
    >> 2008-08-02 13:52:23.411 OFXImport[27702:10b] *** -[OFXTransaction
    >> copyWithZone:]: unrecognized selector sent to instance 0xf4fb80
    >
    > Have you used the debugger to set a breakpoint on
    > objc_exception_throw and see what's trying to copy your object?
    >
    > --
    > Adam
    >
  • Greetings.
    I Do Have another question.

    when the Array is filled on application init, the data displays fine,
    but if I add to the array "programatically"
    the new data is not displayed, i've tried:
    [self didChangeValueForKey:@"transactions"];
    and [transactionTableView reloadData];

    But both have no effect.

    any help is appreciated.
    thank you all.

    Sandro/

    On 2-Aug-08, at 3:43 PM, Adam R. Maxwell wrote:

    >
    > On Aug 2, 2008, at 11:03 AM, Sandro Noel wrote:
    >
    >> Greetings,
    >>
    >> I don't quite know how to explain this.. :) so please excuse me if
    >> I'm not very precise.
    >
    > [...]
    >
    >> 2008-08-02 13:52:23.411 OFXImport[27702:10b] *** -[OFXTransaction
    >> copyWithZone:]: unrecognized selector sent to instance 0xf4fb80
    >
    > Have you used the debugger to set a breakpoint on
    > objc_exception_throw and see what's trying to copy your object?
    >
    > --
    > Adam
    >
  • On Aug 2, 2008, at 2:07 PM, Sandro Noel wrote:

    > when the Array is filled on application init, the data displays
    > fine, but if I add to the array "programatically"
    > the new data is not displayed, i've tried:
    > [self didChangeValueForKey:@"transactions"];
    > and [transactionTableView reloadData];

    If you're using bindings, you can't just manipulate an NSMutableArray
    instance variable directly and expect it to post KVO notifications.
    And don't try to "cheat" and put KVO notifications around all of  the
    various manipulation of your mutable array, either; you'll clutter
    your code and wind up with subtle bugs if you forget one or use the
    wrong one in the wrong case.

    Instead, just use -mutableArrayValueForKey: to get a proxy to the
    property and manipulate that.  It will post KVO notifications and also
    manipulate the instance variable that you have backing the property.
    If you need to intercept the modifications to your property, you can
    override the mutable-array KVC methods described in <Foundation/
    NSKeyValueCoding.h> or in the Key-Value Coding Guide.

      -- Chris
  • Chris.

    Thank you for the explaination!!

    but it leaves me with a question, where should i use it.

    I'm actually adding objects to the array, using addObject message, in
    the model,
    where should i use the mutableArrayValueForKey, and what keyPath
    should I use.

    the workflow is quite simple, the user selects a file, the controller
    calls my model to load the file in various classes,
    and one of the property of the model is transactions which is a
    MutableArray,
    that array is bound to the array controller, which is in turn
    providing the tableview with data.

    I'm new to cocoa... sorry bout that.
    thank you for your help.

    On 2-Aug-08, at 8:08 PM, Chris Hanson wrote:

    > On Aug 2, 2008, at 2:07 PM, Sandro Noel wrote:
    >
    >> when the Array is filled on application init, the data displays
    >> fine, but if I add to the array "programatically"
    >> the new data is not displayed, i've tried:
    >> [self didChangeValueForKey:@"transactions"];
    >> and [transactionTableView reloadData];
    >
    >
    > If you're using bindings, you can't just manipulate an
    > NSMutableArray instance variable directly and expect it to post KVO
    > notifications.  And don't try to "cheat" and put KVO notifications
    > around all of  the various manipulation of your mutable array,
    > either; you'll clutter your code and wind up with subtle bugs if you
    > forget one or use the wrong one in the wrong case.
    >
    > Instead, just use -mutableArrayValueForKey: to get a proxy to the
    > property and manipulate that.  It will post KVO notifications and
    > also manipulate the instance variable that you have backing the
    > property.  If you need to intercept the modifications to your
    > property, you can override the mutable-array KVC methods described
    > in <Foundation/NSKeyValueCoding.h> or in the Key-Value Coding Guide.
    >
    > -- Chris
    >
  • On Sat, Aug 2, 2008 at 9:15 PM, Sandro Noel <sandro.noel...> wrote:
    > Chris.
    >
    > Thank you for the explaination!!
    >
    > but it leaves me with a question, where should i use it.
    >
    > I'm actually adding objects to the array, using addObject message, in the
    > model,
    > where should i use the mutableArrayValueForKey, and what keyPath should I
    > use.

    My general strategy for this is to never access the instance variable
    directly, except when implementing init, dealloc and the KVC
    accessors. All other access (even from other methods of the same
    class) uses the proxy returned by mutableArrayValueForKey:. Something
    like:

    @interface MyClass : NSObject {
      NSMutableArray *myObjects;
    }

    @end

    @implementation MyClass

    -(id)init {
      if(self = [super init]) {
        myObjects = [[NSMutableArray alloc] init];
      }
      return self;
    }

    -(void)dealloc {
      [myObjects release];
      [super dealloc];
    }

    -(NSUInteger)countOfMyObjects {
      return [myObjects count];
    }

    -(id)objectInMyObjectsAtIndex:(NSUInteger)index {
      return [myObjects objectAtIndex: index];
    }

    -(void)insertObject:(id)object inMyObjectsAtIndex:(NSUInteger)index {
      [myObjects insertObject: object atIndex: index];
    }

    -(void)removeObjectFromMyObjectsAtIndex:(NSUInteger)index {
      [myObjects removeObjectAtIndex: index];
    }

    -(void)doSomething {
      NSMutableArray *arrayProxy = [self mutableArrayValueForKey: @"myObjects"];

      [arrayProxy addObject: ...];
      [arrayProxy removeObjectAtIndex: ...];
      //Or any other NSMutableArray calls
    }

    @end

    That way, all edits to the array provide the appropriate notifications
    to any observing objects. It also allows me to change the
    implementation at a future date, and only have to change the
    accessors. The reason that it is safe to access the array directly in
    init and dealloc is that another object can't yet be listening at the
    time of init (also the reason that your code worked when you initially
    filled the array), and by the time of -dealloc, all of the observers
    should have stopped their listening.

    > the workflow is quite simple, the user selects a file, the controller calls
    > my model to load the file in various classes,
    > and one of the property of the model is transactions which is a
    > MutableArray,
    > that array is bound to the array controller, which is in turn providing the
    > tableview with data.
    >
    > I'm new to cocoa... sorry bout that.
    > thank you for your help.

    --
    Clark S. Cox III
    <clarkcox3...>
  • Clark, thank you!
    Great Example.

    I just find it sad, that implementing KVC-KVO, is not enough to get
    the ball rolling,
    and that i have to proxy my model classes to make it work. :(

    I guess i'll have to rethink my Model classes :) and really separate
    functionality from data.
    even if that functionality is manipulating the data itself.

    Ah, still learning :)

    Sandro.

    On 3-Aug-08, at 11:56 AM, Clark Cox wrote:

    > On Sat, Aug 2, 2008 at 9:15 PM, Sandro Noel <sandro.noel...>
    > wrote:
    >> Chris.
    >>
    >> Thank you for the explaination!!
    >>
    >> but it leaves me with a question, where should i use it.
    >>
    >> I'm actually adding objects to the array, using addObject message,
    >> in the
    >> model,
    >> where should i use the mutableArrayValueForKey, and what keyPath
    >> should I
    >> use.
    >
    > My general strategy for this is to never access the instance variable
    > directly, except when implementing init, dealloc and the KVC
    > accessors. All other access (even from other methods of the same
    > class) uses the proxy returned by mutableArrayValueForKey:. Something
    > like:
    >
    > @interface MyClass : NSObject {
    > NSMutableArray *myObjects;
    > }
    >
    > @end
    >
    > @implementation MyClass
    >
    > -(id)init {
    > if(self = [super init]) {
    > myObjects = [[NSMutableArray alloc] init];
    > }
    > return self;
    > }
    >
    > -(void)dealloc {
    > [myObjects release];
    > [super dealloc];
    > }
    >
    > -(NSUInteger)countOfMyObjects {
    > return [myObjects count];
    > }
    >
    > -(id)objectInMyObjectsAtIndex:(NSUInteger)index {
    > return [myObjects objectAtIndex: index];
    > }
    >
    > -(void)insertObject:(id)object inMyObjectsAtIndex:(NSUInteger)index {
    > [myObjects insertObject: object atIndex: index];
    > }
    >
    > -(void)removeObjectFromMyObjectsAtIndex:(NSUInteger)index {
    > [myObjects removeObjectAtIndex: index];
    > }
    >
    > -(void)doSomething {
    > NSMutableArray *arrayProxy = [self mutableArrayValueForKey:
    > @"myObjects"];
    >
    > [arrayProxy addObject: ...];
    > [arrayProxy removeObjectAtIndex: ...];
    > //Or any other NSMutableArray calls
    > }
    >
    > @end
    >
    >
    > That way, all edits to the array provide the appropriate notifications
    > to any observing objects. It also allows me to change the
    > implementation at a future date, and only have to change the
    > accessors. The reason that it is safe to access the array directly in
    > init and dealloc is that another object can't yet be listening at the
    > time of init (also the reason that your code worked when you initially
    > filled the array), and by the time of -dealloc, all of the observers
    > should have stopped their listening.
    >
    >> the workflow is quite simple, the user selects a file, the
    >> controller calls
    >> my model to load the file in various classes,
    >> and one of the property of the model is transactions which is a
    >> MutableArray,
    >> that array is bound to the array controller, which is in turn
    >> providing the
    >> tableview with data.
    >>
    >> I'm new to cocoa... sorry bout that.
    >> thank you for your help.
    >
    > --
    > Clark S. Cox III
    > <clarkcox3...>
previous month august 2008 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Go to today