-1

I want to translate my current program to Swift and I am getting hung up on the simplest things.

I am trying to read a plist enter image description here

But I want to do this one at a time.

i.e. - if we are trying to call the image candy hearts.jpg (we obviously need to add the extension jpeg.

This is what I found on on the net.

var myDict: NSDictionary?
    if let path = NSBundle.mainBundle().pathForResource("data", ofType: "plist") {
        myDict = NSDictionary(contentsOfFile: path)
      //  self.data
    }
    if let dict = myDict {
        // Use your dict here
    }

This is what I originally used iOS6

NSString *pathOfDataTitle = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"];
NSMutableArray *arrayOfTitle = [[NSMutableArray alloc] initWithContentsOfFile:pathOfDataTitle];
self.Datalist = arrayOfTitle;
Jason
  • 168
  • 1
  • 12

1 Answers1

0

This worked
var data: NSArray? var imagename : String!

func readlist(var filename:String) -> NSArray{
    var myDict: NSArray?
    let path = NSBundle.mainBundle().pathForResource(filename, ofType: "plist")

    if (path != nil){
        var val:String
        val=path!;

        myDict = NSArray(contentsOfFile: val)
        var list=myDict;


    }
    if let dict = myDict {
        return myDict!;

    }
    return myDict!;
}

}

Jason
  • 168
  • 1
  • 12