Selecting A Random Item From An Array iOS -
i'm trying use didfinishpickingmediawithinfo when user have picked photo. when have picked photo, want generate item array uilabel, this:
-(void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info { nsarray *myarray = [nsarray arraywithobjects:@"test1",@"test2",@"test3",@"test4",@"test5",@"test6", nil]; int numberofobjects = self.yourarrayofstrings.count; nsinteger randomnumberinrange = arc4random() % numberofobjects; nsstring *randomtext = [myarray objectatindex:randomnumberinrange]; self->_label.text = randomtext; }
but error: "property 'yourarrayofstrings' not found on object of type 'fdviewcontroller *'" on line: "int numberofobjects = self.yourarrayofstrings.count;".
i don't know should replace yourarrayofstrings with. ideas?
nsinteger randomnumberinrange = arc4random() % [myarray count];
Comments
Post a Comment