ios - How to add string and array -
nsstring *butterfly = [nsstring stringwithformat:@"brush_%d.png", i]
i want string in separate
- brush_
- %d.png
because have lot of animation function there in project(0 39).
if(counter == 0) { nsmutablearray *dashboy = [nsmutablearray array]; (i = 1; i<= 13; i++) { butterfly = [nsstring stringwithformat:@"brush_%d.png", i]; if ((image = [uiimage imagenamed:butterfly])) [dashboy addobject:image]; } [stgimageview setanimationimages:dashboy]; [stgimageview setanimationduration:2.0f]; [stgimageview startanimating]; } . . if(counter == 39) { nsmutablearray *dashboy1 = [nsmutablearray array]; (i = 1; <= 30; i++) { butterfly = [nsstring stringwithformat:@"catch_%d.png", i]; if ((image = [uiimage imagenamed:butterfly])) [dashboy1 addobject:image]; } [stgimageview setanimationimages:dashboy1]; [stgimageview setanimationduration:7.20f]; [stgimageview startanimating]; }
i tried it's not correct
nsarray *c = [nsarray arraywithobjects:@"brush", @"catch", @"clap",@"dog", nil]; //nsstring *str = @"brush_"; nsstring *str = [c componentsjoinedbystring:@""]; (int i=0; i<=3;i++) str = [str stringbyappendingformat:@"_%i.png ",i]; nslog(@"%@",str); //output brushcatchclapdog_0.png _1.png _2.png _3.png
i want
brush_0.png, catch_1.png, clap_2.png in array
here want combine in 1 function using loop above category.it possible 1 function combine above 39 animation function.
[self animatewithcategory:@"brush_" withcount:13 duration:0.2f] -(void)animatewithcategory:(nsstring *)strcategory withcount:(cgfloat)count duration:(nsinteger)duration{ nsmutablearray *dashboy = [nsmutablearray array]; (int = 1; i<= count; i++) { nsstring* butterfly = [nsstring stringwithformat:@"%@%d.png",strcategory ,i]; uiimage *image=[uiimage imagenamed:butterfly]; [dashboy addobject:image]; } [stgimageview setanimationimages:dashboy]; [stgimageview setanimationduration:duration]; [stgimageview setanimationrepeatcount:1]; [stgimageview startanimating]; }
Comments
Post a Comment