Tag Archives: swift

how to http post special chars in swift

Questions: I’m using the following to post an email and password to my server (php script). The problem I’m having is the password contains a special char (specifically the & symbol) which seems to be getting stripped. I presume because it thinks its separating variables being passed. How can I pass this char without it… Read More »

UIKeyboardWillShowNotification returning incorrect frame for swift keyboard

Questions: I am using UIKeyboardWillShowNotification and UIKeyboardWillHideNotification to handle keyboard. This is the function called when keyboard is shown : -(void) keyboardWillShow:(NSNotification *)note { CGRect keyboardBounds; //[[note.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] getValue: &keyboardBounds]; NSValue* keyboardFrameBegin = [note.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey]; keyboardBounds = [keyboardFrameBegin CGRectValue]; } I get keyboardBounds = (0, 524, 320, 44) and I am using 5s. No idea… Read More »

Swift: TableView in ViewController

Questions: I have a ViewController in the MainstoryBoard. I added the TableView to it. MainStoryBoard: In addition I have an array outside of the ViewController class and I want the objects inside the array to be shown in the TableView. I can’t figure out how to do it. I connected the delegate between the TableView… Read More »

What are best practices for validating email addresses in Swift?

Questions: I’m looking for the simplest and cleanest method for validating email (String) in Swift. In Objective-C I used this method, but if I rewrite it to Swift, I get an error ‘Unable to parse the format string’ when creating predicate. – (BOOL) validateEmail: (NSString *) candidate { NSString *emailRegex = @”[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}”; NSPredicate *emailTest =… Read More »

Detect if the application in background or foreground in swift

Questions: is there any way to know the state of my application if it is in background mode or in foreground . Thanks Answers: [UIApplication sharedApplication].applicationState will return current state of applications, UIApplicationStateActive UIApplicationStateInactive UIApplicationStateBackground we need to call like let state: UIApplicationState = UIApplication.sharedApplication().applicationState // or use let state = UIApplication.sharedApplication().applicationState if state ==… Read More »

Parsing large XML from server while downloading with LibXML2 in Swift 3

Questions: I have a Problem with the SAX parser from LibXML2 in Swift 3. I want something like XMLPullParser from Android in iOS. Which downloads XML from a server and while downloading it parses the Stream. My XML looks like this: <?xml version=”1.0″ encoding=”UTF-8″ ?> <ResultList id=”12345678-0″ platforms=”A;B;C;D;E”> <Book id=”1111111111″ author=”Author A” title=”Title A” price=”9.95″… Read More »

Parsing large XML from server while downloading with LibXML2 in Swift 3

Questions: I have a Problem with the SAX parser from LibXML2 in Swift 3. I want something like XMLPullParser from Android in iOS. Which downloads XML from a server and while downloading it parses the Stream. My XML looks like this: <?xml version=”1.0″ encoding=”UTF-8″ ?> <ResultList id=”12345678-0″ platforms=”A;B;C;D;E”> <Book id=”1111111111″ author=”Author A” title=”Title A” price=”9.95″… Read More »

PhpMailer vs. SwiftMailer? [closed]

Questions: I’m building a fairly simple php script that will need to send some emails with attachments. I’ve found these 2 libraries to do this. Does either one have significant advantages over the other? Or should I just pick one at random and be done with it? Answers: I was going to say that PHPMailer… Read More »