Cannot invoke 'indexOf' with an argument list of type '(ChecklistItem)'
In order to use indexOf
the ChecklistItem
must adopt Equatable protocol. Only by adopting this protocol the list can compare an item with other items to find the desired index
Cannot invoke with an argument list of type '(UInt64)'
Your problem is the different int types you're using.
First let's check the writePosition
method. You use an Int8
as parameter. So you need to make sure that you also call the method with a Int8
as parameter. To make sure you are using an Int8
you can cast it:
bleService.writePosition(Int8(position))
As you see here, you need to cast the position
to Int8
.
Now check your sendPosition
method. There you've got a similar problem. You want a UInt8
as parameter, but you call it with a UInt64
parameter. That's something you can't do. You need to use the same integer type:
self.sendPosition(UInt8(self.currentClawValue.value))
Here it's the same. Use UInt8
instead of UInt64
to make the casting work.
Cannot invoke '_' with an argument list of type '_' - Which of the two choices should I use?
You have a lot of type mismatch error.
The type of x
should not be UInt8
because x
to increase until the value of the width.
for var x:UInt8 = 0; x < width * 4; x += 4 { // error: '<' cannot be applied to operands of type 'UInt8' and 'Int'
So fix it like below:
for var x = 0; x < width * 4; x += 4 {
To increment the pointer address, you can use advancedBy()
function.
buf += bprow(UnsafeMutablePointer(UInt8)) // error: '+=' cannot be applied to operands of type 'UnsafeMutablePointer<UInt8>' and 'size_t'
Like below:
var pixel = buf.advancedBy(y * bprow)
And this line,
RGBtoHSV(r, g, b) // error
There are no implicit casts in Swift between CGFloat
and Float
unfortunately. So you should cast explicitly to CGFloat
.
RGBtoHSV(CGFloat(r), g: CGFloat(g), b: CGFloat(b))
The whole edited code is here:
func RGBtoHSV(r: CGFloat, g: CGFloat, b: CGFloat) -> (h: CGFloat, s: CGFloat, v: CGFloat) {
var h: CGFloat = 0.0
var s: CGFloat = 0.0
var v: CGFloat = 0.0
let col = UIColor(red: r, green: g, blue: b, alpha: 1.0)
col.getHue(&h, saturation: &s, brightness: &v, alpha: nil)
return (h, s, v)
}
// process the frame of video
func captureOutput(captureOutput:AVCaptureOutput, didOutputSampleBuffer sampleBuffer:CMSampleBuffer, fromConnection connection:AVCaptureConnection) {
// if we're paused don't do anything
if currentState == CurrentState.statePaused {
// reset our frame counter
self.validFrameCounter = 0
return
}
// this is the image buffer
var cvimgRef = CMSampleBufferGetImageBuffer(sampleBuffer)
// Lock the image buffer
CVPixelBufferLockBaseAddress(cvimgRef, 0)
// access the data
var width = CVPixelBufferGetWidth(cvimgRef)
var height = CVPixelBufferGetHeight(cvimgRef)
// get the raw image bytes
let buf = UnsafeMutablePointer<UInt8>(CVPixelBufferGetBaseAddress(cvimgRef))
var bprow = CVPixelBufferGetBytesPerRow(cvimgRef)
var r: Float = 0.0
var g: Float = 0.0
var b: Float = 0.0
for var y = 0; y < height; y++ {
var pixel = buf.advancedBy(y * bprow)
for var x = 0; x < width * 4; x += 4 { // error: '<' cannot be applied to operands of type 'UInt8' and 'Int'
b += Float(pixel[x])
g += Float(pixel[x + 1])
r += Float(pixel[x + 2])
}
}
r /= 255 * Float(width * height)
g /= 255 * Float(width * height)
b /= 255 * Float(width * height)
//}
// convert from rgb to hsv colourspace
var h: Float = 0.0
var s: Float = 0.0
var v: Float = 0.0
RGBtoHSV(CGFloat(r), g: CGFloat(g), b: CGFloat(b)) // error
}
Cannot invoke 'performOperation' with an argument list of type '(NSAttributedString)'
You need to convert NSAttributedString
to String
because your function accept only String
argument.
This way you can convert NSAttributedString
to String
:
if let result = brain.performOperation(operation.string)
And it will work fine.
Cannot invoke value of type 'NSCalendar.Unit.Type' with argument list '(rawValue: UInt)'
This is because of swift 3 changes in Calendar class.
Change it to -
let components = self.calendarView.calendar.dateComponents([.day, .month, .year], from: date)
Cannot invoke function with an argument list of type '()'
The way of initializing AVAudioRecorder
using its initializer in Swift 2 is to leave out the parameter of type NSErrorPointer
and catch it:
do
{
audioRecorder = try AVAudioRecorder(URL:filePath, settings:[:])
}
catch let error as NSError
{
printf(error.description)
}
Cannot invoke 'perform' with an argument list of type '(_)'
The do
keyword creates a scope inside of its curly braces, like an if
or for
loop, meaning the request you create is inside the first scope and not available in the second. Since in both cases you're doing the same thing with the same error, you can just move the perform
call inside the same scope.
let callbackURL = URL(string: "OdinMobile://")!
do {
let amount = try SCCMoney(amountCents: money, currencyCode: "USD")
let request : SCCAPIRequest =
try SCCAPIRequest(
callbackURL: callbackURL,
amount: amount,
userInfoString: userInfoString,
merchantID: nil,
notes: notes,
customerID: nil,
supportedTenderTypes: supportedTenderTypes,
clearsDefaultFees: clearsDefaultFees,
returnAutomaticallyAfterPayment: true
)
try SCCAPIConnection.perform(request)
} catch let error as NSError {
print(error.localizedDescription)
}
Related Topics
How to Integrate Payu Money in Swift
How to Tell If an iOS Device Has a Gps
Displaying Youtube Video Ads with Youtube Iframe
What Is the Expected Behaviour of Facebook Login
Why Self.Locationmanager Stopupdatinglocation Doesn't Stop Location Update
Breaking on Unrecognized Selector
How to Change Swiftui Textfield Style After Tapping on It
How to Detect Whether an iOS Device Is in Silent Mode or Not
Carthage Build Failed Xcode 12 12A7209 Building
I Just Want to Open Ms Outlook App and See Mailto Screen Using Url Scheme at iOS
Getting the Action of Uigesturerecognizer in iOS
Refresh Only the Custom Header Views in a Uitableview
Make Uisearchcontroller Search Bar Automatically Active
Urlsessiondelegate Function Not Being Called
Not Working Transitions in Spritekit
Programmatically Determine Current Target (Run or Test) in iOS Project