xcode - Downcast from UITabBarItem? to UITabBarItem only unwraps optionals; did you mean to use '!' Error -


my code working in xcode6. but, after updating xcode7 got 20 errors , 50 warnings.this might syntax change in swift 2

solved can't figure out 1 : downcast uitabbaritem? uitabbaritem unwraps optionals; did mean use '!' below actual code:

let tabitems = tabbar.items as! [uitabbaritem]  // error in  line (index, value) in enumerate(tabitems) {     var imagename = imagenames[index]     value.image = uiimage(named: imagename)     value.imageinsets = uiedgeinsetsmake(5.0, 0, -5.0, 0) } 

it shows me 1 error

when tried doing this:

if let tabitems = tabbar.items [uitabbaritem]? { (index, value) in tabitems.enumerate() {     var imagename = imagenames[index]     value.image = uiimage(named: imagename)     value.imageinsets = uiedgeinsetsmake(5.0, 0, -5.0, 0) } } 

it showing me 5 errors::

  1. "_uttypecopypreferredtagwithclass", referenced from: -[pffile _mimetype] in parse(pffile.o) 2. "_uttypecreatepreferredidentifierfortag", referenced from: -[pffile _mimetype] in parse(pffile.o) 3. "_kuttagclassfilenameextension", referenced from: -[pffile _mimetype] in parse(pffile.o) 4."_kuttagclassmimetype", referenced from: -[pffile _mimetype] in parse(pffile.o) ld: symbol(s) not found architecture x86_64 5.clang: error: linker command failed exit code 1 (use -v see invocation)

please help! in advance

if there tabbaritems, tabbar.items return array of uitabbaritem. if not return nil (it optional ). "dumb" cast again [uitabbaritem]. saying: have many apples, make apples out of it. need handle case tabbar.items nil. need unwrap tabbar.items adding "!" this:

 let tabitems = tabbar.items!  

this should work :)


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -