ios - Array types are now written with the brackets around the element type -


here's code (taskmanager.swift):

import uikit  var taskmgr: taskmanager = taskmanager ()  struct task {     var name = "untitled"     var desc = "none" }  class taskmanager: nsobject {     var tasks = task[]()      func addtask (name: string, desc: string) {         tasks.append (task (name: name, desc: desc))     } } 

then got this

/users/david/documents/360drive/xcode/try/randomtries/todolist/todolist/taskmanager.swift:11:21: array types written brackets around element type

it says

fix-it: insert "["

i clicked it, line (line 11) turned this:

var tasks = [task[]() 

and got these errors

/users/david/documents/360drive/xcode/try/randomtries/todolist/todolist/taskmanager.swift:11:26: expected ']' in container literal expression /users/david/documents/360drive/xcode/try/randomtries/todolist/todolist/taskmanager.swift:11:26: expected ',' separator /users/david/documents/360drive/xcode/try/randomtries/todolist/todolist/taskmanager.swift:13:5: expected expression in container literal /users/david/documents/360drive/xcode/try/randomtries/todolist/todolist/taskmanager.swift:14:15: cannot invoke 'append' argument list of type '(task)'

thanks advices!

and here 2 errors in firstviewcontroller.swift:

/users/david/documents/360drive/xcode/try/randomtries/todolist/todolist/firstviewcontroller.swift:21:14: 'text' unavailable: apis deprecated of ios 7 , earlier unavailable in swift /users/david/documents/360drive/xcode/try/randomtries/todolist/todolist/firstviewcontroller.swift:22:30: cannot assign 'detailtextlabel' in 'cell'

and here's code

import uikit  class firstviewcontroller: uiviewcontroller, uitableviewdelegate, uitableviewdatasource {      override func viewdidload() {         super.viewdidload()         // additional setup after loading view, typically nib.     }      override func didreceivememorywarning() {         super.didreceivememorywarning()         // dispose of resources can recreated.     }      func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int {         return taskmgr.tasks.count     }      func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {         let cell: uitableviewcell = uitableviewcell (style: uitableviewcellstyle.subtitle, reuseidentifier: "default")         cell.textlabel = ""         cell.detailtextlabel = ""         //cell.text = taskmgr.tasks[indexpath.row].name         //cell.detailtextlabel = taskmgr.tasks[indexpath.row].desc         return cell     }  } 

it looks fix-it blew it. swift uses brackets around type. correct version this:

var tasks = [task]() 

this shorthand notation; there longer version:

var tasks = array<task>() 

but shorthand version preferred.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -