Xcode循环到数组

时间:2015-09-21 12:22:14

标签: ios xcode

对于循环错误; 我想重复[Demophoto]行 请有人帮帮我

示例文件:https://www.dropbox.com/s/177kvpp72pfh8ul/myTest.zip?dl=0

allPhoto = [NSMutableArray array];
[allPhoto addObject:@"http://www.ed.ac.uk/polopoly_fs/1.129149!/fileManager/Mohamad-Hanif-Awang-Senik_2ndLRG.jpg"];
[allPhoto addObject:@"http://thehandmadephotograph.com/wp-content/uploads/2014/08/smithsonian-photo-contest-winner-2012-crop.jpg__800x600_q85_crop.jpg"];
[allPhoto addObject:@"https://cdn.tutsplus.com/photo/uploads/legacy/352_greatphototuts/greatPhotoTuts-68.jpg"];



  [self setPhotos:@[

    for(int i=0; i < [allPhoto count]; i++){
        [DEMOPhoto photoWithProperties: @{@"imageFile": @"1.jpg" }],
    }

 ]];

1 个答案:

答案 0 :(得分:1)

我想这就是你想要的:

NSMutableArray *tempArray = [NSMutableArray new];
for(int i=0; i < [allPhoto count]; i++){
    [tempArray addObject:[DEMOPhoto photoWithProperties: @{@"imageFile": @"1.jpg" }]];
}
[self setPhotos:tempArray];