Friday 15 June 2012

ios - Use of unresolved identifier 'indexPath' in Swift -



ios - Use of unresolved identifier 'indexPath' in Swift -

hello i'm creating variable url , i'm getting error in line.

here's total code.

"use of unresolved identifier 'indexpath' in swift"

import uikit import mediaplayer class detailviewcontroller: uiviewcontroller{ var movieplayer:mpmovieplayercontroller! var color = uicolor.whitecolor() var name = nsstring() var arrayofprograms: nsarray = [] var url = nsstring() override func viewdidload() { super.viewdidload() self.navigationcontroller?.navigationbar.titletextattributes = [nsfontattributename: uifont(name: "helveticaneue-light", size: 20)!, nsforegroundcolorattributename: uicolor.whitecolor()] self.navigationcontroller?.navigationbar.tintcolor = color self.navigationitem.title = "tv joj" var url = nsurl(string: (self.arrayofprograms.objectatindex(indexpath).program).url) movieplayer = mpmovieplayercontroller(contenturl: url) movieplayer.view.frame = cgrect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height) movieplayer.view.sizetofit() self.view.addsubview(movieplayer.view) movieplayer.fullscreen = true movieplayer.controlstyle = mpmoviecontrolstyle.embedded } override func supportedinterfaceorientations() -> int { homecoming int(uiinterfaceorientationmask.portrait.rawvalue) } }

i'm sorry i'm beginner..

cells

var arrayofprograms: nsarray = [] arrayofprograms = [program(name: "markíza", url: "http://1.com")]

this how i'm trying pass info through segue

override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject!) { var indexpath: nsindexpath = self.tableview?.indexpathforselectedrow() nsindexpath! var destinationviewcontroller: detailviewcontroller (segue.destinationviewcontroller detailviewcontroller).url = (self.arrayofprograms.objectatindex(indexpath.row) program).url

i want url open different video each named cell. arraysofprograms cells.

to expand on mundi's reply - these lines -

var url = nsurl(string:(self.arrayofprograms.objectatindex(indexpath).program).url) movieplayer = mpmovieplayercontroller(contenturl: url)

can written this, bit more clear -

var url = self.arrayofprograms.objectatindex(indexpath).program.url; movieplayer = mpmovieplayercontroller(contenturl: url);

the main issue variable "indexpath" doesn't exist anywhere in programme not telling programme index out of arrayofprograms array.

like mudi said, if "indexpath" defined nsindexpath isn't type want pass in there anyways, you'd want pass in indexpath's row. this

// indexpath isn't want want. illustration illustrate point. var indexpath = nsindexpath(forrow: 1, insection: 0) // getting row (1) variable indexpath var url = self.arrayofprograms.objectatindex(indexpath.row).program.url movieplayer = mpmovieplayercontroller(contenturl: url)

what trying do? want to loop through arrayofprograms , create film player each item thats in array? or should in table view , when user clicks on specific row. answering questions help figure out "indexpath" supposed come from.

ios xcode swift

No comments:

Post a Comment