po Swift String unresolved identifier
This is most likely a bug in the debug information output. You can check this by grabbing the PC, for instance from register read pc
, and then doing:
(lldb) image lookup -va <PC VALUE>
That will print a bunch of stuff, but the last entries will be all the variables currently visible to the debugger, and where they live (in registers or memory.) If you don't see the variable there, then the debug information must have told lldb that the variable is not currently live.
If you can reproduce this in some example code you can make available, please file a bug with bug reporter.apple.com.
Use of Unresolved Identifier Error Code
var changeInPercentString = quoteDict["ChangeInPercent"] as! String
let changeInPercentStringClean: NSString = (changeInPercentString as NSString).substringToIndex((changeInPercentString as NSString).length-1)
How to debug Use of unresolved identifier in Swift?
This is a perfect lesson in why indentation is important. There's a second }
after the end of USERPOST_REF: DatabaseReference
, which ends the scope of the class DataService
.
As a result, createNewAccount(uid:user:)
and createNewUserPost(userpost:)
are standalone functions without access to any instance members of DatabaseReference.
A few points of improvement:
- Swift convention for all properties, instance, class or static, is to use lowerCamelCase.
- Unlike other languages (Java and Ruby are the main offenders here that I know of), there is no point making an instance variable with a public getter (computed property), such as
filprivate _x: Int
, with apublic var x: Int
. Namely, because_x
is not an instance variable. Swift doesn't actually let you make instance variables. They're generated for you when you create properties. What you're doing is writing a property that accesses a property you declared, to access an instance variable the compiler synthesized. There's no need for this. Just make the property's setter scoped to file private. - The conventional name of a singleton in Swift is
shared
,default
ormain
. Try to stick with one of those. Additionally, in order for you to truly have a singleton, you need to restrict access to the initializer, by declaring it withprivate
access.
Here is what I would recommend:
class DataService {
static let shared = DataService()
private init() {}
public fileprivate(set) var baseDB = Database.database().reference()
public fileprivate(set) var userDB = Database.database().reference()
public fileprivate(set) var userPostDB = Database.database().reference()
var currentUser: DatabaseReference {
let userID = UserDefaults.standard.value(forKey: "uid") as! String
return Database.database()
.reference()
.child(byAppendingPath: "user")
.child(byAppendingPath: userID)
}
func createNewAccount(uid: String, user: Dictionary<String, String>) {
// A User is born?
userDB.child(byAppendingPath: uid).setValue(user)
}
func createNewUserPost(userpost: Dictionary<String, AnyObject>) {
// Save the Post
// userPostDB is the parent of the new USERPOST: "userposts".
// childByAutoId() saves the userpost and gives it its own ID.
let firebaseNewUserPost = userPostDB.childByAutoId()
// setValue() saves to Firebase.
firebaseNewUserPost?.setValue(userpost)
}
}
Use of unresolved identifier 'MapTasks' in Swift
If you fully read that tutorial, you will find in the instruction that you need to create a file name MapTasks which is a class.
You can just copy this file from GitHub and add it to your project.
Use of unresolved identifier - app development with Swift Project 2
Try correctWordLabel.text = currentGame.formattedWord
I think it’s a typo.
Earlier in your code you create an instance of the Game struct called currentGame
so you are accessing the formattedWord variable inside that instance. That’s why you couldn’t change it to Game. Game is like the blueprint of the struct. currentGame is your actual ‘thing’ Hope that makes some sense.
po in LLDB with swift
That error sounds like it might be because DWARF is not telling LLDB where to find your self
object. Given the nature of Swift, LLDB needs to know the type of self in order to be able to inject an expression inside your local scope.
One way to find out if that is your problem is to do at the LLDB prompt:
(lldb) frame variable -L self
You are probably going to not see a location for it. Worth filling a bug report for, just to track your specific repro case.
Anyway, to get to the bulk of your question. In Swift, there is no language-sanctioned mechanism for "print description" like for ObjC, so while you can type po self
, unless self is an Objective-C type, you will pretty much see the same thing that "p self" or even "frame variable self" would tell you - which is entirely based on the LLDB data formatters mechanism. If you want to hook into that to customize the way your Swift objects look, the obligatory reference is: http://lldb.llvm.org/varformats.html
Related Topics
How to Open File Dialog with Swiftui on Platform "Uikit for MAC"
Sum Values of Properties Inside Array of Custom Objects Using Reduce
Swift 3 Get Start Index (As Int) of Substring
Swift Realm, Load the Pre-Populated Database the Right Way
How to Get Day and Month from Date Type - Swift 4
Getting Path for Resource in Command Line Tool
When Should I Use Optionals and When Should I Use Non-Optionals with Default Values
How to Use Swift Package Manager with an Existing MACos Project
Image Upload in Vapor 3 Using Postgresql
Using Swift Library in Xamarin
How to Utilize Nslock to Prevent a Function from Firing Twice
Uitableview - Multiple Selection and Single Selection
How to Append a Character to a String in Swift
Using Swift to Disable Sleep/Screen Saver for Osx