xcode - New in Objective C. Simple bug at runtime. Thread 1: breakpoint 1.1 -
i learning objective c , have tried override superclass (nsobject) description method in bnritem class. though seems have done right, nslog not seem use overridden description method. instead see thread 1 breakpoint 1.1 in definition of description method , more precisely, defined descriptionstring.
here console output.
2015-08-30 20:49:00.622 randomitems[46034:1002101] 0 2015-08-30 20:49:00.623 randomitems[46034:1002101] 1 2015-08-30 20:49:00.623 randomitems[46034:1002101] 2 2015-08-30 20:49:00.623 randomitems[46034:1002101] 3 (lldb)
my main.m file:
#import <foundation/foundation.h> #import "bnritem.h" int main(int argc, const char * argv[]) { @autoreleasepool { // create mutable array object, store address in items variable... nsmutablearray *items = [[nsmutablearray alloc] init]; //send message addobject: nsmutablearray pointed //by variable item, passing string each time [items addobject:@"one"]; [items addobject: @"two"]; [items addobject: @"three"]; // send message, insertobject:atindex;, same array object [items insertobject:@"zero" atindex:0]; // every item in items array ... (nsstring *item in items){ //log description of item nslog(@"%@", item); } // create bnritem instance , log instance variables in console bnritem *item = [[bnritem alloc] init]; // set item name red sofa item.itemname = @"red sofa"; item.serialnumber= @"a1b2c"; item.valueindollards = 100; // nslog(@"%@", item); //destroy mutable array object items = nil ; } return 0; }
my header file:
#import <foundation/foundation.h> @interface bnritem : nsobject { nsstring *_itemname; nsstring *_serialnumber; int _valueindollards; nsdate *_datecreated; } - (void)setitemname:(nsstring *)str; - (nsstring *)itemname; - (void)setserialnumber:(nsstring *)str; - (nsstring *)serialnumber; - (void)setvalueindollards:(int)v; - (int)valueindollards; - (nsdate *)datecreated; @end
and finally, implementation file:
#import "bnritem.h" @implementation bnritem - (void)setitemname:(nsstring *)str { _itemname = str; } - (nsstring *)itemname { return _itemname; } - (void)setserialnumber:(nsstring *)str { _serialnumber = str; } - (nsstring *)serialnumber { return _serialnumber; } - ( void )setvalueindollards:(int)v { _valueindollards = v; } - ( int )valueindollards { return _valueindollards; } -( nsdate * )datecreated { return _datecreated; } - ( nsstring * )description { nsstring *descriptionstring = [[nsstring alloc] initwithformat:@"%@ (%@): worth %d, recorded on %@", self.itemname, self.serialnumber, self.valueindollards, self.datecreated]; return descriptionstring; } @end
it sounds have set breakpoint on line in -description
method. debugger stopping program @ breakpoint. there's no indication of actual error.
if hit continue button in xcode, program proceed fine.
you can disable breakpoint, tell xcode ignore breakpoints, or delete breakpoint if don't want break there. breakpoint blue arrow in margins left of code. right-click or control-click on see options.
to make xcode ignore breakpoints, toggle breakpoint button in debugging toolbar. looks right-pointing arrow. filled in blue if breakpoints enabled. outline if they're disabled.
Comments
Post a Comment