Posts

Showing posts from March, 2024

predicate with avoid child entity iOS swift

 Problem: I had my coredata entity that main entity had one level of subentity with the same entity.But in predicate i want to avoid the subentity entry but if subentity has the predicated text then main entity wants to be came.How can i achieve that? Solution: First you have to add issubentity in the coredata entity and enter if subentity then true otherwise it will be false.Then follow the below code.                     predicateStringAdd. append ( NSPr edicate ( format :  "(time.startsOn >= %@ OR ANY subEntity.time.startsOn >= %@) AND isSubEntity != true" ,time1,time2)) the above will be based on start above start time and below endtime. You can check with string as like below                     predicateString. append ( NSPredi cate ( format :  "( name  CONTAINS[c] %@ OR  ANY  subEntity.name  CONTAINS[c] %@ OR desc CONTAINS[c] ...

popover size based on content iOS swift

 Problem: I want to show my popover with it's size based on the content of the popover with it's tableview.How can i achieve that? Solution: In viewdidload of the popover call the code as like below and achieve that.          DispatchQueue. main . asyncAfte r ( deadline : . now () + 0.1) {               self . preferredContentSize   =   self . mytbl . contentSize           }

Textfield validation rxswift iOS || Textfield restrict the length using rxswift

 Problem: I want to validate my textfield to restrict that to enter particular length of characters only.Not to exceed that limit.How can i achieve that? Solution: You have to add one extension function for your textfield with sending limits and disposebag to that textfield extension and restrict like below. func extension UITextField {      func   validate ( limit : Int , dispose : Dis poseBag ) {          self . rx . text .orEmpty         . scan ( "" ) { (previous, new) ->  String   in              if  new.count > limit  {                  return  previous ??  String (new. prefix (40))             }  else  {                  return  new             }     ...