Firebase Fetching Data in Swift [closed] - ios

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I can fetch data from firebase console. But how to get node from the database.
Please refer to below code :
let current_uid = FIRAuth.auth()?.currentUser?.uid
self.userRef?.queryOrdered(byChild: "Email").observe(FIRDataEventType.childAdded) { (snapshot : FIRDataSnapshot) in
let value = snapshot.value as? NSDictionary
let email = value?["Email"] as? String
let password = value?["Password"] as? String
print("User Email \(email!) and User Password \(password!)")
}
But i am bit confuse how to get 4dS6fdWy4of8VyDN8eouwqIk38j2 remember i have to fetch all the users from the database.
Any help will be appreciated.

Related

What path should be used to write to iPhone's memory? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
i am trying to save a string to device's memory for a simple to do app. It works great on a simulator where i set the path for writing to memory to be - let path: String = directory + "App4.txt". But when running this on an actual iPhone it doesn't save to memory.
This is the function.
if let directory: String = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.AllDomainsMask, true).first {
let path: String = directory + "App4.txt"
userInputString = userInput.joinWithSeparator("-")
// Writing.
do {
try userInputString.writeToFile(path, atomically: false, encoding: NSUTF8StringEncoding)
}
catch {
print("Error")// Error handling here.
}
}
Any help is very much appreciated!! :)
As #Martin-R is alluding to, you need to have a "/" in your path between directory and the file name.

swift if statement check string not correctly [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
in my iOS app, i have a simple if statement like this:
if (responseString! != "No Data") {
print("Data available")
}
if I print the responseString, this is the result:
No Data
But the print "Data available" will shown as well.
why?
There might be whitespaces or newlines in your responseString, try this:
let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)?.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())

What is the best way to use if([names count]>1) in swift? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
In Objective C we used
if([names count]>1){
// array count is greater than one
}
The same way i tried to check in swift. But the complier shouts.
Any idea??
The correct way to write it should be:
if name.count > 1 {
// Your code here
}
Your syntax is incorrect. Brackets are used in Objective-C, not Swift.
Try this:
var shoppingList = ["Eggs", "Milk"]
if(1 < shoppingList.count) {
println( "Greater than one")
}

SWIFT: Why I can't get the current URL loaded in UIWebView? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I need to get the current URL loaded into the webview and this is how I'm trying to get that but it gives me this error: "Cannot convert the exporessions type 'ST7??' to type 'String'
and this is the code
var currentURL : NSString = webView.request?.URL.absoluteString!
What is wrong with this?
If you put parentheses around this, the error goes away:
let currentURL : NSString = (webView.request?.URL.absoluteString)!
Beware that yours might not be just a syntax problem.
If your webView is in a state where request == nil your app will crash at runtime.
I'd rather write something like:
if let currentURL = webView.request?.URL.absoluteString {
// do things ...
// Your currentURL will be automatically bridged to Swift's String type
} else {
// Just in case request is nil ...
}

save string variable in NSMutableArray -Error [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm new to iOS and its development. Here I'm passing string value to saveStringpath variable then I want to save it in type NSMutable array saveStrings but I'm getting:
thread 1 exc_bad_access (code=2 type breakspoint
please help me.
//here i need to save these data in NSMutable array
-(void)saveNSMutablearray:(NSString*)saveStringpath
{
//start Mutable array to save this values
NSMutableArray *saveStrings =[[NSMutableArray alloc]init];
[saveStrings addObject:saveStrings];
NSString *test = [saveStrings objectAtIndex:0];
NSLog(#"JSON:-----vm %#", test);
}
The problem you are facing is because of wrong variable name. In your code you are adding array into array, so to solve the problem please change this line:
[saveStrings addObject:saveStrings];
into that one:
[saveStrings addObject:saveStringpath];
and the problem is gone :)

Resources