Cannot Call Value of Non-Function Type 'Ciimage'

Cannot call value of non-function type 'CIImage?'

It's because, once inside UIImage, the term CIImage is seen as the CIImage property of UIImage, due to implicit self as message recipient — in other words, Swift turns your CIImage into self.CIImage and it's all downhill from there.

You can solve this by disambiguating thru Swift's use of module namespacing:

extension UIImage {
func foo() {
let ciImage = UIKit.CIImage(image:UIImage())
}
}

EDIT In Swift 3 this problem will go away, because all properties will start with small letters. The property will be named ciImage, and there will be no confusion with the CIImage class.

Cannot call value of non-function type 'UIImage?'

To set the property image of an existing UIImageView, you need to assign it a new instance of UIImage:

PersonsChoice.image = UIImage(named: option[randomNumber])

Same thing for the text of a UILabel:

resultLabel.text = "It's a draw!"

Cannot call value of non-function type 'Any'

DataSnapshot.value is Any and according to the documentation you could cast it in different types.

Data types returned: + NSDictionary + NSArray + NSNumber (also includes booleans) + NSString

If I understood your snipped well, in you case, you need to cast "DataSnapshot" into a dictionary in order to access with a subscript.
You can try this:

databaseRef.child("ServiceA").queryOrderedByKey().observe(.childAdded, with: {
DataSnapshot in
let title = (snapshot.value as? [String: Any])?["title"] as? String
self.posts.insert(PostStruct.init(title: title), at: 0)
})

Please also note that, in order to prevent crashes, I removed the force-wrap so "title" would be an optional String.

Error: Cannot call value of non-function type

The error occurs from the fact that the vc parameter points to an instance of UIViewController, and from how the method looks like you want to instead call the initializer on the controller class.

You could use Self, and drop the first argument, this will make the loadFromNib method really simple. Another optimization that you could make would be to declare the nib name as optional, and give it a default value of nil:

extension UIViewController {
static func loadFromNib(_ nibName: String? = nil) -> Self {
return self.init(nibName: nibName, bundle: nil)
}
}

You'd then be able to nicely use the method like this:

let vc = MyViewController.loadFromNib() // loads from MyViewController.nib

, or

let vc = MyViewController.loadFromNib("Custom") // loads from Custom.nib

cannot call value of non-function type '[UIImage]

If you're simply trying to generate a random image, here is a much simpler solution:

import UIKit

let images = [
UIImage(named: "emoji01.png")!,
UIImage(named: "emoji02.png")!,
UIImage(named: "emoji03.png")!,
UIImage(named: "emoji04.png")!,
UIImage(named: "emoji05.png")!
]

func getRandomImage() -> UIImage {
let number = Int(arc4random_uniform(images.count))
return images[number]
}

What this is doing:

This creates a set of images -

let images = [...]

This creates a function -

func getRandomImage() -> UIImage {

Note: the -> UIImage part means that the function actually returns an image. You can't return something in a void function.

This creates a random number -

let number = ...

This returns the image -

return images[number]

Cannot call value of non-function type 'NSManagedObjectContext' using CoreData

I assume you meant

if textView == textTextView {
if let text = textTextView.text, let context = container?.viewContext {
_ = try? Entry.findOrCreatEntry(matching: text, in: context)
}
...


Related Topics



Leave a reply



Submit