data science 강좌가 있는 한국 웹사이트
How to use predicates with fetchRequest in Core Data
original source : https://stackoverflow.com/questions/41641705/how-to-use-predicates-with-fetchrequest-in-core-data
First of all get rid of all NSString
and NSDictionary
occurrences. This is Swift!. Use the Swift native structs String
and Dictionary
.
Second of all put always all good code in the do
scope of a do - catch
block.
A CoreData predicate has a simple format attribute == value
which is very similar to aContact.uniqueId! == contactIdentifierString
:
var contactIdentifierString = ""
func userSelectedContact(contactIdentifier: String) {
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
do {
let fetchRequest : NSFetchRequest<Contact> = Contact.fetchRequest()
fetchRequest.predicate = NSPredicate(format: "uniqueId == %@", contactIdentifier)
let fetchedResults = try context.fetch(fetchRequest) as! [Contact]
if let aContact = fetchedResults.first {
providerName.text = aContact.providerName
}
}
catch {
print ("fetch task failed", error)
}
}
The code assumes that there is a NSManagedObject
subclass Contact
containing
@nonobjc public class func fetchRequest() -> NSFetchRequest<Contact> {
return NSFetchRequest<Contact>(entityName: "Contact")
}
How to use predicates with fetchRequest in Core Data
original source : https://stackoverflow.com/questions/41641705/how-to-use-predicates-with-fetchrequest-in-core-data
First of all get rid of all NSString
and NSDictionary
occurrences. This is Swift!. Use the Swift native structs String
and Dictionary
.
Second of all put always all good code in the do
scope of a do - catch
block.
A CoreData predicate has a simple format attribute == value
which is very similar to aContact.uniqueId! == contactIdentifierString
:
var contactIdentifierString = ""
func userSelectedContact(contactIdentifier: String) {
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
do {
let fetchRequest : NSFetchRequest<Contact> = Contact.fetchRequest()
fetchRequest.predicate = NSPredicate(format: "uniqueId == %@", contactIdentifier)
let fetchedResults = try context.fetch(fetchRequest) as! [Contact]
if let aContact = fetchedResults.first {
providerName.text = aContact.providerName
}
}
catch {
print ("fetch task failed", error)
}
}
The code assumes that there is a NSManagedObject
subclass Contact
containing
@nonobjc public class func fetchRequest() -> NSFetchRequest<Contact> {
return NSFetchRequest<Contact>(entityName: "Contact")
}
How do I pass data from a tab bar controller to one of its tabs?
original source : https://stackoverflow.com/questions/10661275/how-do-i-pass-data-from-a-tab-bar-controller-to-one-of-its-tabs
#1 answer
https://stackoverflow.com/a/39090496/3151712
Using Swift
If you have UINavigationController
as one of the tabs in UITabBarController
, you want to get the instance of the child view controller instead of creating a new instance and push it to the navigation view controller before changing the tab view index. You can do this…
This sample code assumes the Navigation Controller is at the first tab (index 0) and “childViewController” is embedded in the Navigation Controller.
let viewControllers = self.tabBarController?.viewControllers
let navController = viewControllers![0] as! UINavigationController
let profileViewController = self.storyboard?.instantiateViewControllerWithIdentifier("childViewController") as? ProfileViewController
profileViewController!.parameter1 = "Value1"
profileViewController!.parameter2 = "Value2"
navController.pushViewController(profileViewController!, animated: true)
self.tabBarController?.selectedIndex = 0
How do I pass data from a tab bar controller to one of its tabs?
original source : https://stackoverflow.com/questions/10661275/how-do-i-pass-data-from-a-tab-bar-controller-to-one-of-its-tabs
#1 answer
https://stackoverflow.com/a/39090496/3151712
Using Swift
If you have UINavigationController
as one of the tabs in UITabBarController
, you want to get the instance of the child view controller instead of creating a new instance and push it to the navigation view controller before changing the tab view index. You can do this…
This sample code assumes the Navigation Controller is at the first tab (index 0) and “childViewController” is embedded in the Navigation Controller.
let viewControllers = self.tabBarController?.viewControllers
let navController = viewControllers![0] as! UINavigationController
let profileViewController = self.storyboard?.instantiateViewControllerWithIdentifier("childViewController") as? ProfileViewController
profileViewController!.parameter1 = "Value1"
profileViewController!.parameter2 = "Value2"
navController.pushViewController(profileViewController!, animated: true)
self.tabBarController?.selectedIndex = 0
Swift: Firebase 3 – How to Load Entire Chat Log per User (Ep 12)
my review point is 8/10
https://youtu.be/azFjJZxZP6M?t=1m40s table view에서 하나의 row를 선택한경우 ( didSelectRowAtIndexPath )
https://youtu.be/azFjJZxZP6M?t=10m38s UICollectionViewDelegateFlowLayout 사용하여 collection view 스타일 수정하기
https://youtu.be/azFjJZxZP6M?t=10m45s collection view cell size 설정하기
https://youtu.be/azFjJZxZP6M?t=12m firebase에서 여러개의 데이터를 가져오는 방법
https://youtu.be/azFjJZxZP6M collection view cell 을 만드는 방법
https://youtu.be/azFjJZxZP6M?t=22m22s collection view 에 cell view를 등록하는 방법
https://youtu.be/azFjJZxZP6M?t=27m40s collection view 를 드래그 해서 바운스 되게 하는 작업
Swift: Firebase 3 – How to Load Entire Chat Log per User (Ep 12)
my review point is 8/10
https://youtu.be/azFjJZxZP6M?t=1m40s table view에서 하나의 row를 선택한경우 ( didSelectRowAtIndexPath )
https://youtu.be/azFjJZxZP6M?t=10m38s UICollectionViewDelegateFlowLayout 사용하여 collection view 스타일 수정하기
https://youtu.be/azFjJZxZP6M?t=10m45s collection view cell size 설정하기
https://youtu.be/azFjJZxZP6M?t=12m firebase에서 여러개의 데이터를 가져오는 방법
https://youtu.be/azFjJZxZP6M collection view cell 을 만드는 방법
https://youtu.be/azFjJZxZP6M?t=22m22s collection view 에 cell view를 등록하는 방법
https://youtu.be/azFjJZxZP6M?t=27m40s collection view 를 드래그 해서 바운스 되게 하는 작업