1

I using the LJWebImage sample project, Which,I found from github on the following link https://github.com/likumb/LJWebImage. Project,similar to SDWebImage.I am successfully imported the sample project into my main project.I am using collectionView to populating the image from plist which contain number of url links.I am trying to shuffle the plist Array when collectionView loaded.I am using the following code to populate collectionView.

  import UIKit

  class AppInfo: NSObject {

  var icon: String?


  class func appInfo() -> NSArray {

    let path = Bundle.main.path(forResource: "apps", ofType: "plist");

    let apps = NSArray(contentsOfFile: path!)!

   let appInfos = NSMutableArray()

    // I am trying to shuffle the array using the following random function
    ///////////////////////////////////////////////////////////////////////

    let randomIndex = Int(arc4random_uniform(UInt32(apps.count)))

    print(apps[randomIndex])

    /////////////////////////////////////////////////////////////////


    for obj in apps{

        let appInfo = AppInfo()

        appInfo.setValuesForKeys(obj as! [String : AnyObject])

        appInfos.add(appInfo)

    }

    return appInfos

 }

 }
Joe
  • 8,868
  • 8
  • 37
  • 59
  • I am answering my own question. I imported GameplayKit to the above class and i used shuffled() function to shuffle plist array once my collectionView loaded.this simple piece of code solved my problem.... – Joe Sep 26 '16 at 04:12

0 Answers0