xcode - Trouble saving segmented control with core data -
i thought issue simple 1 on come, it's providing little harder , frustrating.
i'm using uisegmentedcontrol make selection , saved core data nsnumber entity. unfortunately when try convert integer segment control nsnumber, comes (null). below sample code of problem.
// viewcontroller.h #import <uikit/uikit.h> #import "object.h" @interface viewcontroller : uiviewcontroller @property (weak, nonatomic) iboutlet uisegmentedcontrol *segmentoutlet; @property (strong, nonatomic) object *currentobject; //core data object entity named subobject nsnumber - (ibaction)segmentcontrolselected:(id)sender; @end //viewcontroller.m -(ibaction)segmentcontrollerselected { [self.segmentoutlet selectedsegmentindex] // segment control currentobject.subobject = [nsnumber numberwithint:([self.segmentoutlet selectsegmentindex]); nslog(@"the object number %@", currentobject.subobject); }
the nslog %@ result (null), i'm not sure how correct this.
i've started learn programming, it's basic rookie mistake. help
your segmentoutlet
needs specified strong
. memory system discarding @ point; then, when try self.segmentoutlet
return value nil
. after invoking selectsegmentindex
fails and, default, returns nil
, 'null'. try:
@property (strong, nonatomic) iboutlet uisegmentedcontrol *segmentoutlet;
Comments
Post a Comment