Posts

Showing posts from August, 2020

How to get the label value from contacts using phone number || cnlabel get string swift || CNContact get the name label and name

 Solution:    Below you can find the label and name from the phone number.        for  cont  in  place. phoneNumbers         {            let  replaced = cont. value . stringValue . replaci ngOccurrences (of:  "[^0-9+]" , with:  "" , options:  NSString . CompareOptions . regula rExpression , range: nil )            if  replaced  ==  my phoneNumber                     {                        let  localizedLabel =  CNLabeledValue < NSString >. local izedString (forLabel: cont. label !)                        let  PhoneLabel  = localizedLabel                        break                               }                  else                    {                            continue                    }          }

CollectionView SwipecollectionCell after edit collectionView not resigned

 Solution: Before you have to call the below method don't reload the cell.  func   hideSwipeCollectionViewCells () {        print ( CollView . indexP athsForSelectedItems )          for  cell  in   workSpaceCollView . visibleCells  {              if   let  cell = cell  as ?  SwipeCollectionViewCell  {                 cell. hideSwipe (animated:  false )             }         }     }

Common tableView cell for more rows display crash while using different cell iOS swift

 Solution: If you are using different cells for a particular section then must return every section with cell.Because if you are using two section with one common cell and another two sections with another cell then declare it in every section with cell and return it.Don't use in common cell for few cells.Because iOS not allow you to reuse more cells in particular section.Only one cell to be returned for every section.

Cannot add something to an array swift

 Problem: I want add some values to an array iOS swift.Not able to add in that. Solution: It's not possible to add values in an array.You can assign values to an array is possible. In NSMutableArray only you can add values in that dynamically. var value:NSArray! value.addObject(some value).    ////not possible var value:NSMutableArray! value.addObject(some value).    ////possible

How the reset works coredata iOS swift

 Solution: Reset the last changed context will be available If you saved the context then it will not be available.So if you want to reset then before save try that to reset.

Cell button action not works instead of that cell didselect row calls swift || collection View button action not works instead of that cell didselect row calls swift || didselect called while tapping button in collectionview swift

Problem: I had a cell with button and some set of views.I added the target to that button.If i clicked that button target calls and also the cell didselect row calls. How to disable the didselect call in button click action. Solution: If you added the target then didselect also will be called.So you must avoid add target to a button in a cell.Instead of you can add the tap gesture to the button and call the action.It will avoid to call didselect method.                    let  singleTap =  UITapGestureRecognizer (target:  self , action: #selector ( self . didTapAction ( _ :)))                   singleTap. numberOfTapsRequired  =  1                   Cell. Btn . addGest ureRecognizer (singleTap)

Delete a drawn CGPoint in a View iOS swift || Delete CGPoint in an imageVIew

  Solution : You cannot remove the points from the view.Instead of that you can redraw or re-initialize the view. You cannot be delete the drawn image in that.Because it was set as like image view background.So you cannot be clear.You must be re initiate it.

Convert some value to CGPoint objective C

Solution: CGPoint value = [points[0] CGPointValue];

Get CGPoints from CGMutablePath || Find min and max values from CGMutablePath || iOS find MINX,MINY,MAXX,MAXY from CGMutablePath

Solution: let value = path.getPathElementsPoints() let xArray = value.map(\.x) let yArray = value.map(\.y) let minX = xArray.min()!-drawingPenRectAdj let maxX = xArray.max()!+drawingPenRectAdj let minY = yArray.min()!-drawingPenRectAdj let maxY = yArray.max()!+drawingPenRectAdj print("min x",minX) print("max x",maxX) print("min y",minY) print("max y",maxY) let points = NSMutableArray() points.add(CGPoint(x: minX, y: minY)) points.add(CGPoint(x: maxX, y: maxY)) var covertPoints:[CGPoint] = [] var cgpath:CGMutablePath! = CGMutablePath.init() for i in 0..<value.count { let point = value[i] covertPoints.append(CGPoint(x: point.x-(minX), y: point.y-(minY))) } cgpath.addLines(between: covertPoints) points.add(cgpath) return points

print CGRect objective c

Problem: Want to print the cgrect of a button in iOS objective C. Solution: NSLog(@"close button frame = %d",NSStringFromCGRect(self.RectView.Button.frame));

Get the updated objects in coredata for rollback

Solution:          print ( appdel . getContext (). up datedObjects ) It will display the updated objects that are changed after the last commit.If you are tried with