Posts

Showing posts with the label iOS

Xcode 11 Features

Image
Some of the XCode 11 features are: SwiftUI Minimap Rich Documentation Swift Package Manager Inline Diff Transform iPad Apps to Mac Debugging and Simulators Let’s look into each of these one by one. 1. SwiftUI SwiftUI is the big announcement this year. It’s a new framework introduced for easily creating layouts using swift code. Moreover, Xcode shows us a real app like interface viewer side by side while you edit the Swift file. It requires a Declarative syntax which is easy to use Swift code. Adding animations and stuff is all very easy. Xcode 11 Swiftui This is a major shift from the Storyboards and drag and drop setup. The only issue: SwiftUI is available from iOS 13 and above. It is not backward compatible with the current old iOS versions. Hence use it only if your app supports iOS 13 and above. To use SwiftUI, select the toolbox from the project setup window as shown below: Xcode Swiftui Setup 2. Minimap Xcode has an awesome looking minimap of your code at the left. You can quickl...

How to validate email id in iPhone SDK?

Image
This is prefect method to validate email address valid or not. In this method I'm using " NSPredicate" and "Name Regex" to validate email-ID NSString *email = textFieldemail.text; NSString *emailRegEx = @"(?:[a-z0-9!#$% \\ &'*+/=? \\ ^_`{|}~-]+(?: \\ .[a-z0-9!#$% \\ &'*+/=? \\ ^_`{|}" @"~-]+)*| \" (?:[ \\ x01- \\ x08 \\ x0b \\ x0c \\ x0e- \\ x1f \\ x21 \\ x23- \\ x5b \\ x5d- \\ " @"x7f]| \\\\ [ \\ x01- \\ x09 \\ x0b \\ x0c \\ x0e- \\ x7f])* \" )@(?:(?:[a-z0-9](?:[a-" @"z0-9-]*[a-z0-9])? \\ .)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?| \\ [(?:(?:25[0-5" @"]|2[0-4][0-9]|[01]?[0-9][0-9]?) \\ .){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-" @"9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[ \\ x01- \\ x08 \\ x0b \\ x0c \\ x0e- \\ x1f \\ x21" @"- \\ x5a \\ x53- \\ x7f]| \\\\ [ \\ x01- \\ x09 \\ x0b \\ x0c \\ x0e- \\ x7f])+) \\ ])"; NSPredicate *regExPredicate = [NSPredicate predicateWithFormat:@"SELF...

How to use nsxmlparser in Iphone SDk?

Image
NSXMLParser is a forward only reader or an event driven parser. What it means is, an event is raised whenever the parser comes across a start of an element, value, CDATA and so on. The delegate of NSXMLParser can then implement these events to capture XML data. Some of the events are raised multiple times like the start of an element, value of an element and so on. Since NSXMLParser is known as an event driven parser, we can only read data at the present node and cannot go back. The iPhone only supports  NSXMLParser  and not  NSXMLDocument , which loads the whole XML tree in memory. Books Application To understand how to use an instance of NSXMLParser, let’s create a simple navigation based application where we will list the title of the book in the table view and upon selecting a title, display the detail information in a detail view. Click  here  to see the sample XML file, used in this application. Create a new application in XCode by selecting Navig...

How to create Singleton in iPhone?

Image
One of the most useful patterns that we have employed in our iPhone game is the singleton. For those who don’t know, singletons are a class that only gets instantiated once in your application’s run-time. They often take the form of manager or factory classes. A good example of a singleton is the  web-based resource manager class  that we posted about recently. We have been using singletons for a variety of things in our cocos2d-based game. Including: ·         Resource management ·         Atlas sprite managers ·         User settings management ·         Score management Below is a template for the singletons that we use in objective-c. Note : A singleton does not need to be explicitly allocated or initialized (the   alloc   and   init  methods will be called automatically on fir...