Posts

How to use the objective c files inside the swift project?

Image
Hai friends , if you confused for using the objective c files already you had but you had developed the app with swift.Then don't worry, apple had already the setup for the migration. Just you can drag and drop the objective c files inside your swift project it says an alert to create a Bridging header.After that you must select the yes then it will create the bridging header. Then you have to open the bridging header file and import the .h files of your objective c files.Then you can clean your project and import the file inside of your swift view controller file. Then you can easily access the variables and functions inside of your swift file.

TableView error Assertion Failiure when try to load the data

Image
When you tried to display the array of values in tableView but you got the below error. Error: Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:] The first thing you have to check with your tableView.Because if you not connected the delegate and data source to the taableView then you got the above error. Also if you did not add the table view data source and table view delegate then the above error will come.So add the delegate and data source things like below. class  ViewController: UIViewController , UITableViewDataSource , UITableViewDelegate { } Data source and delegate methods are connected from ViewController to tableView like below. You must have to implement the required delegate methods inside the View Controller.

CoreData Class used twise Error iOS Swift

Image
When you created coreData and tried to run then if it displays error as "the class name of coreData model className used twice in folder and CoreData".Then try the following steps to solve the issue.Select your coreData model object.Select third option in the right side menu. In above submenu Class->codegen->select as Manual/None. Then rebuild the code.The error is resolved Now.

Keyboard with done button and text field will scroll based on the keyboard height iOS swift

Hai friends, I know you had tired for implementing text field delegate and implement the delegate method codes in all the pages.when you follow the code it's easy to hadle the return button, Done button and more. If you want the keyboard with done button.Also when the keyboard appears when a text field is editing the text field wants to show above the keyboard.Keyboard with the next and previous button.The above three scenarios are fulfilled by using the IQKeyboardManager. First, we want to install the cocoa pods in the system and integrate the IQ keyboard manager. import the IQKeyboard in the app delegate.        import IQKeyboardManagerSwift Inside app delegate adds the below code inside the didfinishlaunchingoptions function. In every text field or textView the keyboard will have done, next, prev buttons and also the when keyboard up then the text field will go up and show the editing.

Location-based data validation when app is in terminated state iOS Swift

Hai friends, I know you had tried for location manager for getting the location updates in the background.But it was not possible from the location manager.In LocationManger we can get the location updates and location based data triggering in the foreground only.If we want to do it in terminated state also we can go with GEOFENCING. We will trigger the functions in terminated state with monitoring the locations using geofencing.

UILocalNotification alarm sound does not trigger when app is in Active state iOS Swift

When the app is in foreground app will not trigger the sound of the notification.It will directly come to the app updates.So you can use the AVPlayer to trigger the sound manually when app receives the notification. Code:     func application( _ application: UIApplication , didReceive notification: UILocalNotification ) {          if application. applicationState == . active { //here play the sound using AVPlayer } }

Navigate Particular ViewController from appdelegate in NavigationViewController stack

When you are in AppDelegate you want to navigate to the particular view in Navigation stack.You will use the window as rootViewController then navigate to the particular ViewController using the navigation stack. Code:                 var rootViewController = self .window!.rootViewController as ! UINavigationController                 rootViewController.pushViewController(ViewController, animated: true )