0

My code was working well in Xcode 6. But, after updating to Xcode 7 I got nearly 20 errors and 50 warnings.This might be some syntax change in Swift 2

Solved all those but can't figure out this one : Downcast from UITabBarItem? to UITabBarItem only unwraps optionals; did you mean to use '!'

let tabItems = tabBar.items as! [UITabBarItem]  // Error in  this line
    for (index, value) in enumerate(tabItems)
    {
        var imageName = imageNames[index]
        value.image = UIImage(named: imageName)
        value.imageInsets = UIEdgeInsetsMake(5.0, 0, -5.0, 0)
    }

Please help! Thanks in advance

Suprem Vanam
  • 73
  • 11

1 Answers1

0

Try this:

if let tabItems = tabBar.items as [UITabBarItem]? {
    for (index, value) in tabItems.enumerate()
    {
        var imageName = imageNames[index]
        value.image = UIImage(named: imageName)
        value.imageInsets = UIEdgeInsetsMake(5.0, 0, -5.0, 0)
    }
}

You see the error because items now have type [UITabBarItem]?

Skie
  • 1,942
  • 16
  • 27
  • No, It is 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 for architecture x86_64 5.clang: error: linker command failed with exit code 1 (use -v to see invocation) – Suprem Vanam Sep 29 '15 at 17:09
  • Seems there are other errors exists beyond this. You need to check other code too. PFFile is part of Parse framework. Please update it to the latest version and check that you installed it properly. Maybe some dependent frameworks not included: http://stackoverflow.com/questions/18319885/link-errors-with-parse-framework-ios – Skie Sep 30 '15 at 11:46