The following line in cordova plugin code written for Swift 3,
let json = JSON(command.arguments)
is throwing error when built using swift 4.
Pls let me know what change needs to made to make it work in Swift 4.
command.arguments is of type [Any]! and it contains a String which is a json. I am unable to use String.data as it says [Any]! does not have member data
Error is
error: argument labels '(_:)' do not match any available overloads
Related
I am getting an error in Xcode when trying to build an app.
In Firebase Storage-StorageGetDownloadURLTask.swift.
Firebase Storage: 11.0.7
Flutter: 3.0.5
Xcode 12
In a few lines it presents the information:
"Definition conflicts with previous value.
Value of type 'Any?' has no member 'count'.
Value of type 'Any?' has no member 'components'"
I would like to understand why I am getting this error and how to fix it.
I already updated Firebase Storage version from 11.0.1 to 11.0.7.
I removed the podfile.lock.
I removed the Pods.
Flutter clean command, then flutter pub get.
Pod install, pod deintegrate, pod update.
And I wasn't successful.
I'm trying to update the version of my app from flutter 2.2.3 to flutter 3.0.5, I managed to run it on Android, but in Xcode it's showing this error.
The line downloadTokens = dictionary["downloadTokens"] is declaring a constant named downloadTokens with a type of Any?.
The line guard let downloadTokens = downloadTokens as? String is trying to declare a constant named downloadTokens with a type of String.
So you are trying to create two separate constants with the same name but different types, hence the error message of "Definition conflicts with previous value".
Change your code to:
guard let downloadTokens = dictionary["downloadTokens"] as? String,
downloadTokens.count > 0 else {
This combines your two lines into one creating a single constant named downloadTokens with a type of String.
This fix will resolve the other two errors since downloadTokens is not correctly of type String instead of Any?.
I have created an method with an closure that is used to fetch data by an AJax request, parse it and convert it to an struct:
static func getAllByCategory(category : String, completion : #escaping ([MenuItem]) -> Void) -> Void {
The category is needed to define from which category the menu items needs to be fetched.
The implementation is according Swift ok. But when i tried to call this method, Swift gives an strange error: 'Editor placeholder in source file' when adding the category in this call:
MenuData.getAllByCategory(category: self.selectedCategory) { (menuItem) in
}
In the documentation Swift gives an example that looks exactly the same. What did i do wrong?
Thanks!
I did something stupid. Compiler gives error on an automatic piece called code. Error popup shows up on parameter but is caused in content. Problem solved.
I tried to change client page size in Azure server
it's default is 50 and I want to make it bigger
so i use Microsoft tutorial in this link
https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-ios-how-to-use-client-library#querying
var client : MSClient?
let client = MSClient(applicationURLString: "AppUrl")
let table = client.tableWithName("TodoItem")
let query = table.query()
let pullSettings = MSPullSettings(pageSize: 3000)
but when I write
table.pullWithQuery(query, queryId:nil, settings: pullSettings) { (error) in
if let err = error {
print("ERROR ", err)
}
}
there are error "Value of type 'MSTable?' has no member 'pullWithQuery'"
what is the problem ?
is the function name changed ?
Two problems:
The documentation has not been updated for current versions of Swift
(an update request has been filed). The correct function name in modern Swift is pull rather than pullWithQuery.
The pullWithQuery function is on MSSyncTable, not MSTable. Pull is part of the offline sync system. The MSTable analog is read.
More details:
The SDK itself defines the function as MSSyncTable.pullWithQuery, but one of the features of Swift 3.0 is that it renames Objective C methods when it projects them into Swift to remove redundant arguments from the name, so verbWithX(X) becomes just verb(with:x) and pullWithQuery (MSQuery) becomes pull(with:MSQuery).
For more information on Swift 3 changes please see https://swift.org/blog/swift-3-0-released/ . I believe this particular change is SE-0005: Better Translation of Objective-C APIs Into Swift
If you download the Swift quickstart from your Azure Portal then you’ll get the correct modern pattern there:
self.table!.pull(with: self.table?.query(), queryId: "AllRecords")
or with your arguments:
self.table!.pull(with: self.table?.query(), queryId: nil, settings: pullSettings)
I am new to Swift. Trying some coding in Swift 4 beta version.
Here is what I am trying:
var testString = "Testing the string"
this works fine:
testString.insert("!", at: testString.endIndex)
but this won't work:
testString.insert(contentsOf: " there", at: testString.index(before: testString.endIndex))
Extraneous argument label contentsOf: in call.
Swift 4 is supposed to support this right?
Can anyone tell me whats the problem here?
I run your code in Swift 3 and got same error. You may check your Swift version with this command
swift -version
I'm working on a project, utilizing Alamofire + AlamofireImage. I've just installed AlamofireImage via CocoaPods, and I'm getting this error:
Value of type 'Request' has no member 'responseImage'
for the line:
Alamofire.request(.GET, locationURL).responseImage { response in
if let image = response.result.value { // more code
Works fine in all other projects, Podfile install lines are exactly the same as well.
Not sure what the entire issue was, because I didn't have to do this in other projects, but importing AlamofireImage fixes the issue. Weirdest thing.