Found 2041 Articles for Mobile Development

What is embedded bitcode and what does ENABLE_BITCODE do in xcode?

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:24

302 Views

Bitcode – Bitcode is an intermediate reperesentation of how the code looks. This code can not be used by us or can’t be installed on a device. When we upload our application to the app store It is uploaded as an bitcode and later converted to app binary by itunes/Apple.When the Intermediate code is created an uploaded to the App store or run on the device, a program called LLMV takes over the control and converts the Intermediate code to a Binary file which is x86 32Bit or x86 64 bit for the simulator and ARM for the actual iOS handheld ... Read More

What is "Processing Symbol Files" message in Xcode?

Rishi Rathor
Updated on 30-Jul-2019 22:30:24

171 Views

Processing symbol files is a message displayed on xcode when we create a project’s build. When this message appears, in background Xcode downloads files and symbol files for specific device and a specific processor on which build shall be installed.The symbol files contains debug symbols which are used to debug on specific processor and iOS version and when some crash or error occurs, those symbols are used to create crash reports. Once processing symbols is done a new folder with device symbols is created in the library, usually under “~/Library/Developer/Xcode/iOS DeviceSupport/ “.Sometimes our system might get stuck on this step ... Read More

How to get the current version of my iOS project in code?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:24

142 Views

When we build an iOS application, by default it get a version 1.0 and build 0. Whenever we upload a new build to the app store, we need to change the version number. We can update the build number for testing builds. The version and build number are stored in the info.plist file in our project.Sometimes we might need to access the build or the version number in our application to perform some custom action.To get the version number we can use the following code and assign it to a variable or constant.Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! StringTo get the build number ... Read More

Detect current device with UIUserInterfaceIdiom in Swift

Anvi Jain
Updated on 30-Jul-2019 22:30:24

2K+ Views

To detect current device with iOS/Swift we can use UserInterfaceIdiom. It is an enum in swift, which tells which device is being used.The interface idiom provides multiple values in it’s enum which are.case unspecified @available(iOS 3.2, *) case phone // iPhone and iPod touch style UI @available(iOS 3.2, *) case pad // iPad style UI @available(iOS 9.0, *) case tv // Apple TV style UI @available(iOS 9.0, *) case carPlay // CarPlay style UIIn swift interfaceIdiom can be used in the following way:print(UIDevice.current.userInterfaceIdiom) if UIDevice.current.userInterfaceIdiom == .phone { print("running on iPhone") }When we run the above code ... Read More

How to navigate from one view controller to another in iOS?

Vrundesha Joshi
Updated on 29-Jun-2020 14:02:43

5K+ Views

To navigate from one view Controller to another view Controller in iOS, we need to use Navigation controller. Navigation controller manages a stack of View controller when we go from one view to another view.Navigation from one view controller to another view controller can be done like mentioned below.Step 1 − Create a View controller object.let vc = self.storyboard?.instantiateViewController(withIdentifier: "VC2ViewController") as! VC2ViewControllerIn this step we initialize an object of the type of our another view controller, to which we want to navigate. The identifier variable should be same as the identifier of our second view controller.Step 2 − Navigating to ... Read More

How to detect shake gesture using Swift?

Rishi Rathor
Updated on 29-Jun-2020 14:03:26

694 Views

To detect a shake gesture in iOS UIKit provides three different methods, let’s see them one by one.Method 1 − When the shake gesture begins.override func motionBegan(_ motion: UIEvent.EventSubtype, with event: UIEvent?) { // code you want to implement }Method 2 − When the shake gesture ends.override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) { // Code you want to implement. }Method 3 − when the shake gesture is cancelled.override func motionCancelled(_ motion: UIEvent.EventSubtype, with event: UIEvent?) { // code you want to implement. }Now let’s add some code in our motionBegan method, override func motionBegan(_ motion: UIEvent.EventSubtype, with event: ... Read More

How to subtract 1 hour from current time using Swift?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:24

3K+ Views

To subtract hours from a date in swift we need to create a date first. Once that date is created we have to subtract hours from that, though swift does not provide a way to subtract date or time, but it provides us a way to add date or date component in negative value. In this example we’ll see how we can achieve the same.Let’s create a date first, let it be today, let today = Date()Now to modify this date we’ll use the add function with negative value, let modifiedDate = Calendar.current.date(byAdding: .hour, value: -2, to: today)!Now to see ... Read More

Check if string contains special characters in Swift

Anvi Jain
Updated on 29-Jun-2020 14:04:33

2K+ Views

To check if a string contains a special character in swift we can use conditionals like if else or switch but that would need a lot of conditions to be executed, making programming as well as execution time consuming. So in this example we’ll see how to do the same task with regular expressions and another method that swift provides to check if some character exists in a character set.Method 1 − Using regular expressionLet’s create an extension of String and add the following code into thatextension String {    var containsSpecialCharacter: Bool {       let regex = ... Read More

Email & Phone Validation in Swift

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:24

1K+ Views

To validate email and phone in swift language we can use multiple conditional statements like if conditions, but that’s a long process and may contain 50-100s of if statements to validate email.So instead of conditionals we’ll use Regular expression. Swift provides NSPredicates which we can use to evaluate a regular expression and test them.Let’s see how we can use regular expressions to do the same.We’ll create a function which we can use as extension of String class or UIViewController to use through out the project.Add the following code to any class in your Project, or create a separate swift class ... Read More

How to use Bold & Non-Bold Text In A Single UILabel in iOS/iPhone?

Vrundesha Joshi
Updated on 29-Jun-2020 13:59:33

3K+ Views

To use a Bold and a regular/Non-Bold text in a single UILabel, we can either use a storyboard editor to achieve the same, or we can do it programmatically. Let’s see both of them.Method One − Editing with StoryboardSelect the label you want to edit, go to it’s attribute inspector.From the first option Text, select Attributes instead of plain.Write the following text in the label “Bold Regular”Double Click on Bold to select it, and then right click on it to see more options.Select font > Bold from that option. It should do the task.Method Two − Programmatically Achieving the result.Add the ... Read More

Advertisements