Why Is the Swift Compiler Marking This as an Error

Swift Compiler errors


for service: HMService in detailItem!.services
{
if !services.containsObject(service)
{
println(service)
services.addObject(service)
tableView!.insertRowsAtIndexPaths([NSIndexPath(forRow: 0, inSection: 0)], withRowAnimation: UITableViewRowAnimation.Fade)
}
}

this is the code that was crashing for me and all i did was remove the HMService and then it worked. i didnt want to use the properties of HMservice but i could do without it.

so i just did something like this.

for service in detailItem!.services
{
if !services.containsObject(service)
{
println(service)
services.addObject(service)
tableView!.insertRowsAtIndexPaths([NSIndexPath(forRow: 0, inSection: 0)], withRowAnimation: UITableViewRowAnimation.Fade)
}
}

Hope this helps people

Why is it marking it as a compiler error it looks right

You have 1 more ')' than needed. Remove the ) after 273

Xcode 4.5.2 errors are found but Build is marked as Succeeded

Have you tried cleaning the build folder?

In XCode, open the Product menu then hold down option. Clean should change to Clean Build Folder.

Edit:

You can also press + + + K

Swift compiler error using dictionary lookup and cast in optional binding

String is not an object; use NSString instead:

if let stringValue = NSBundle.mainBundle().infoDictionary["CFBundleExecutable"] as? NSString {
...
}

If you want stringValue to be a String instead of an NSString:

if let stringValue:String = NSBundle.mainBundle().infoDictionary["CFBundleExecutable"] as? NSString {
...
}

Enum cases with associated values cannot be marked potentially unavailable with '@available'

See this Swift bug for an explanation and workaround from the Swift compiler team.

This is intentional. The ABI of enum cases with payloads that are potentially unavailable is not well-defined. That this worked in the past was by coincidence of your application not requiring the (potentially unavailable) type metadata for the payload. Please either increase your deployment target or mark Foo itself as available as the least-available case.
https://github.com/apple/swift/pull/36327

So you either need to mark the whole enum as @available(iOS 13.0, *) or need to increase your deployment target to iOS 13.0.



Related Topics



Leave a reply



Submit