objective c - Should I Add Something To The Header File? -
i'm writing app , getting error. not sure how go fixing it. thank you.
the error undeclared identifier 'collectionview'
and header file being imported.
header:
#import <uikit/uikit.h> nsmutabledata *content; @interface amcollectionviewcontroller : uicollectionviewcontroller @property (weak, nonatomic) iboutlet uibarbuttonitem *tagbutton; - (ibaction)tagbuttontouched:(id)sender; @end implementation error occurring
- (void)collectionview:(uicollectionview *)collectionview didselectitematindexpath:(nsindexpath*)indexpath { if(shareenabled){ //determine selected items using indexpath nsstring *selectedphotos = [tagimages[indexpath.section] objectatindex:indexpath]; //add selected image array [selectedphotos addobject:selectedphotos]; } } thanks lot guys
i use collectionview multiple times in same .m file
- (nsinteger)collectionview:(uicollectionview *)collectionview numberofitemsinsection:(nsinteger)section{ return 50; } - (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath{ static nsstring *identifier =@"cell"; amcollectionviewcell *cell = (amcollectionviewcell *)[collectionview dequeuereusablecellwithreuseidentifier:identifier forindexpath:indexpath]; int imagenumber = indexpath.row % 10; cell.imageview.image = [uiimage imagenamed:[nsstring stringwithformat:@"imageicon%d.jpg",imagenumber]]; cell.selectedbackgroundview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"imageborder.jpg"]]; return cell; }
i don't know error,
your second reference
indexpathon line can't right:nsstring *selectedphotos = [tagimages[indexpath.section] objectatindex:indexpath];the
objectatindexparameter needs integer. meant:nsstring *selectedphotos = [tagimages[indexpath.section] objectatindex:indexpath.item];or, more consistent (either use
objectatindexor use[]syntax, using both little curious):nsstring *selectedphotos = tagimages[indexpath.section][indexpath.item];you haven't shown declaration of
tagimages, nor it's initialization, assumetagimagesarray of array of strings? if so, above correction should fix it. if not, should tell howtabimagespopulated/structured.if
selectedphotosnsstring, use ofaddobjectmethod won't possibly work.addobjectmethodnsmutablearraymethod, notnsstringmethod.
Comments
Post a Comment