Posts

Showing posts from November, 2020

Create compose mail when click button iOS swift

Solution:              let  receivers = event. receivers   !=   nil  ? [ receivers ] : []                           let  mailComposerVC =  MFMailComposeViewController ()             mailComposerVC. mailComposeDele gate  =  self     // Extremely important to set the --mailComposeDelegate-- property, NOT the --delegate-- property                          mailComposerVC. setToRecipients (receivers  as ?  NSArray   as ? [ String ])             mailComposerVC. setSubject (  "" )             mailComposerVC. setMessageBody ( "" , isHTML:  false )              self . viewControl . present ( mailComposerVC, animated:  true , completion:  nil ) The above code you have to implement in the action of the button. receivers are the receiving mail id arrays you can pass.Also must have to implement the delegate in the viewController and delegate methods.

Call action implementation iOS swift || Call implementation || phone number call iOS swift || Phone call implementation when click the number iOS swift

Problem: I want to create a button with title of phone number and if the user touches the button it wants to call that phone number. Solution: Just add the below code inside the action of that button and pass the number value. Code:   let  cleanNumber = number. replacingOccurrences ( of:  "[^0-9+]" , with:  "" , options:  NSString . CompareOptions . regula rExpression , range: nil );              if   let  url =  URL (string:  "TEL:// \( String (describing: cleanNumber)) " ) {                  UIApplication . shared . open (url, options: [:], completionHandler:  nil )             }

App crashes when i use nsmutablestring iOS swift

   Solution: @property  ( nonatomic ,  assign )  NSMutableString *  str ; When i use the above line try to run the app it crashes. Because it's a mutable value..  NSMutableString and  NSString are came from nsobject with mutble value.. @property  ( nonatomic ,  weak )  NSMutableString *  str ; You must have to use like above the app will works fine..You cannot be able to assign a value to the mutated objects.You must use that as weak property.. Happy coding...

Reverse for loop in iOS objective C and swift || For loop in descending order

 Solution: Swift: for  i  in  ( 0 ..<array . count ). reversed () { //your code here } Objective C:              for ( int  i =  array . count - 1 ; i >=  0 ; i--){ //your code here } If you want to reverse your array and find the last nearby updated value then use the above method. It will also called as  stack  last in first out.

EKAlarm not works for Event || Alarm added but not triggered to an event iOS swift

   Solution: EKAlarm had different methodology to handle.If you had an event with start date and end date and your event wants to trigger an alarm at the time of event start then you don't have to give the absolute date to the event. If your event wants to trigger an alarm before the event start then you can give the absolute date and time.Then only it will works.If you set an alarm date with same time of an event then it will never trigger an alarm.So carefully update that.            alarm.absoluteDate = e.startDate //avoid this line when event start time and alarm time as same

Create audio player with button icon change in tableview or collectionVIew in iOS swift

   Problem: I want to create an tableview with audio player.If the user taps inside the tableview button it will change the icon of the button and user can able to play and pause the audio. Solution: In tableview cell add the button with its target.Also set the button title and title image for both normal and selected state. Inside the target if button is selected then change the state of the button and play the player. If button is unselected then pause the player or stop the player. If you had different targets for cell then must be use remove the other target's after that add the target that you want to apply. Also want to implement the willdisappear method must be handle to stop the player and change the state of the button. For the above you want to set the tag to the button and access the cell using the tag. If the player reached the endtime of the audio then the delegate method will be called "Didfinishplaying". Inside that you can change the state of the button an