際際滷

際際滷Share a Scribd company logo
ContactBook
仍 亳 从仂仄 仄舒仍仂 亰于亳舒亶仆仂 从仂仆舒从仆仂 从仆亳亢从亳
仂仍亳 亰于亳舒亶仆仂 从仂仆舒从仆仂
从仆亳亢从亳 亰舒仄舒仍仂
 弍仄亠亢亠仆亳亶 于亳弍 仗仂仍于
 亠亰仆 于亠亟亠仆仆 弍亰仆亠-
从仂仆舒从于
 仆仄舒仍亳仆亳亶 仆亠亠亶
 仗于舒仆仆 亟舒仆亳 亟仍 仍亠亞从仂
仆舒于亞舒
 弍亠亞舒仆仆 仆舒亶亰仆仂仄舒仆仆亳 亟舒仆亳
ContactBook
 仆仄舒仍亳仆亳亶 仆亠亠亶
 仗于舒仆仆 亟舒仆亳 亟仍 仍亠亞从仂
仆舒于亞舒
 弍亠亞舒仆仆 仆舒亶亰仆仂仄舒仆仆亳 亟舒仆亳
 丿于亳亟从亠 亰舒仗仂于仆亠仆仆 亟舒仆亳 仆舒 仂仆仂于
于仂亠仆亳 舒弍仍仂仆于
ContactBook
 仆仄舒仍亳仆亳亶 仆亠亠亶
 仗于舒仆仆 亟舒仆亳 亟仍 仍亠亞从仂
仆舒于亞舒
 弍亠亞舒仆仆 仆舒亶亰仆仂仄舒仆仆亳 亟舒仆亳
 丿于亳亟从亠 亰舒仗仂于仆亠仆仆 亟舒仆亳 仆舒 仂仆仂于
于仂亠仆亳 舒弍仍仂仆于
 弌于仂亠仆仆 于仍舒仆亳 舒弍仍仂仆仆亳 仗仂仍于
ContactBook
 仆仄舒仍亳仆亳亶 仆亠亠亶
 仗于舒仆仆 亟舒仆亳 亟仍 仍亠亞从仂
仆舒于亞舒
 弍亠亞舒仆仆 仆舒亶亰仆仂仄舒仆仆亳 亟舒仆亳
 丿于亳亟从亠 亰舒仗仂于仆亠仆仆 亟舒仆亳 仆舒 仂仆仂于
于仂亠仆亳 舒弍仍仂仆于
 弌于仂亠仆仆 于仍舒仆亳 舒弍仍仂仆仆亳 仗仂仍于
 仂亟舒于舒仆仆 仆亠舒弍仍仂仆仆亳 仗仂仍于
ContactBook
 Core Data
亳从仂亳舒仆 亠仆仂仍仂亞
import Foundation
import CoreData
class GroupOfLabels: NSManagedObject {
@NSManaged var title: String?
@NSManaged var contact: Contact?
@NSManaged var details_: NSOrderedSet?
var details : [ContactDetail] {
get {
if let orderedSet = details_ {
return orderedSet.array as! [ContactDetail]
} else {
return []
}
}
set {
details_ = NSOrderedSet(array: newValue)
}
}
convenience init() {
let entity = NSEntityDescription.entityForName("GroupOfLabels",
inManagedObjectContext: AppDelegate.managedObjectContext)
self.init(entity: entity!, insertIntoManagedObjectContext:
AppDelegate.managedObjectContext)
}
}
 Core Data
 NSOperationQueue
亳从仂亳舒仆 亠仆仂仍仂亞
var searchQueue = NSOperationQueue()
searchQueue.qualityOfService = .Background
searchQueue.maxConcurrentOperationCount = 1
func search(searchInObjects searchInObjects: DetailViewCellEditLabel.LabelType, text:
String) {
searchQueue.addOperationWithBlock {
if self.searchQueue.operations.count == 1 {
var indexPath : NSIndexPath!
var resultArrayCount : Int!
switch searchInObjects {
case .Label:
self.filterGroupsByText(text, searchInObjects: .Label)
indexPath = NSIndexPath(forRow: 1, inSection: 0)
resultArrayCount = self.searchResultArray2.count
case .Group:
self.filterGroupsByText(text, searchInObjects: .Group)
indexPath = NSIndexPath(forRow: 2, inSection: 0)
resultArrayCount = self.searchResultArray.count
default: break
}
switch (self.searchCellShow, resultArrayCount) {
case (_, 0):
self.searchAction(.Delete)
case (_, 1) where self.searchResultArray != nil &&
self.searchResultArray.first == text:
self.searchAction(.Delete)
case (_, 1) where self.searchResultArray2 != nil &&
self.searchResultArray2.first?.count == 1 &&
self.searchResultArray2.first?.first?.label == text:
self.searchAction(.Delete)
 Core Data
 NSOperationQueue
 亠亰 于亳从仂亳舒仆仆 IB
亳从仂亳舒仆 亠仆仂仍仂亞
class DetailViewCellDefault : UITableViewCell {
let label = UITextView(editable: false, style: .Label)
let data = UITextView(editable: false, style: .Text)
var cellReuse = false
func setInit() {
contentView.addSubview(label)
contentView.addSubview(data)
contentView.leadingAnchor.constraintEqualToAnchor(label.leadingAnchor).active
= true
contentView.topAnchor.constraintEqualToAnchor(label.topAnchor).active = true
contentView.trailingAnchor.constraintEqualToAnchor(label.trailingAnchor).active
= true
label.bottomAnchor.constraintEqualToAnchor(data.topAnchor).active = true
contentView.leadingAnchor.constraintEqualToAnchor(data.leadingAnchor).active
= true
contentView.trailingAnchor.constraintEqualToAnchor(data.trailingAnchor).active =
true
data.bottomAnchor.constraintEqualToAnchor(contentView.bottomAnchor).active
= true
}
func setConfig(label label: String?, text: String?) {
self.label.text = label
data.text = text
if !cellReuse {
setInit()
cellReuse = true
}
}
磻 亰舒 于舒亞

More Related Content

ContactBook

  • 1. ContactBook 仍 亳 从仂仄 仄舒仍仂 亰于亳舒亶仆仂 从仂仆舒从仆仂 从仆亳亢从亳
  • 2. 仂仍亳 亰于亳舒亶仆仂 从仂仆舒从仆仂 从仆亳亢从亳 亰舒仄舒仍仂 弍仄亠亢亠仆亳亶 于亳弍 仗仂仍于 亠亰仆 于亠亟亠仆仆 弍亰仆亠- 从仂仆舒从于
  • 3. 仆仄舒仍亳仆亳亶 仆亠亠亶 仗于舒仆仆 亟舒仆亳 亟仍 仍亠亞从仂 仆舒于亞舒 弍亠亞舒仆仆 仆舒亶亰仆仂仄舒仆仆亳 亟舒仆亳 ContactBook
  • 4. 仆仄舒仍亳仆亳亶 仆亠亠亶 仗于舒仆仆 亟舒仆亳 亟仍 仍亠亞从仂 仆舒于亞舒 弍亠亞舒仆仆 仆舒亶亰仆仂仄舒仆仆亳 亟舒仆亳 丿于亳亟从亠 亰舒仗仂于仆亠仆仆 亟舒仆亳 仆舒 仂仆仂于 于仂亠仆亳 舒弍仍仂仆于 ContactBook
  • 5. 仆仄舒仍亳仆亳亶 仆亠亠亶 仗于舒仆仆 亟舒仆亳 亟仍 仍亠亞从仂 仆舒于亞舒 弍亠亞舒仆仆 仆舒亶亰仆仂仄舒仆仆亳 亟舒仆亳 丿于亳亟从亠 亰舒仗仂于仆亠仆仆 亟舒仆亳 仆舒 仂仆仂于 于仂亠仆亳 舒弍仍仂仆于 弌于仂亠仆仆 于仍舒仆亳 舒弍仍仂仆仆亳 仗仂仍于 ContactBook
  • 6. 仆仄舒仍亳仆亳亶 仆亠亠亶 仗于舒仆仆 亟舒仆亳 亟仍 仍亠亞从仂 仆舒于亞舒 弍亠亞舒仆仆 仆舒亶亰仆仂仄舒仆仆亳 亟舒仆亳 丿于亳亟从亠 亰舒仗仂于仆亠仆仆 亟舒仆亳 仆舒 仂仆仂于 于仂亠仆亳 舒弍仍仂仆于 弌于仂亠仆仆 于仍舒仆亳 舒弍仍仂仆仆亳 仗仂仍于 仂亟舒于舒仆仆 仆亠舒弍仍仂仆仆亳 仗仂仍于 ContactBook
  • 7. Core Data 亳从仂亳舒仆 亠仆仂仍仂亞 import Foundation import CoreData class GroupOfLabels: NSManagedObject { @NSManaged var title: String? @NSManaged var contact: Contact? @NSManaged var details_: NSOrderedSet? var details : [ContactDetail] { get { if let orderedSet = details_ { return orderedSet.array as! [ContactDetail] } else { return [] } } set { details_ = NSOrderedSet(array: newValue) } } convenience init() { let entity = NSEntityDescription.entityForName("GroupOfLabels", inManagedObjectContext: AppDelegate.managedObjectContext) self.init(entity: entity!, insertIntoManagedObjectContext: AppDelegate.managedObjectContext) } }
  • 8. Core Data NSOperationQueue 亳从仂亳舒仆 亠仆仂仍仂亞 var searchQueue = NSOperationQueue() searchQueue.qualityOfService = .Background searchQueue.maxConcurrentOperationCount = 1 func search(searchInObjects searchInObjects: DetailViewCellEditLabel.LabelType, text: String) { searchQueue.addOperationWithBlock { if self.searchQueue.operations.count == 1 { var indexPath : NSIndexPath! var resultArrayCount : Int! switch searchInObjects { case .Label: self.filterGroupsByText(text, searchInObjects: .Label) indexPath = NSIndexPath(forRow: 1, inSection: 0) resultArrayCount = self.searchResultArray2.count case .Group: self.filterGroupsByText(text, searchInObjects: .Group) indexPath = NSIndexPath(forRow: 2, inSection: 0) resultArrayCount = self.searchResultArray.count default: break } switch (self.searchCellShow, resultArrayCount) { case (_, 0): self.searchAction(.Delete) case (_, 1) where self.searchResultArray != nil && self.searchResultArray.first == text: self.searchAction(.Delete) case (_, 1) where self.searchResultArray2 != nil && self.searchResultArray2.first?.count == 1 && self.searchResultArray2.first?.first?.label == text: self.searchAction(.Delete)
  • 9. Core Data NSOperationQueue 亠亰 于亳从仂亳舒仆仆 IB 亳从仂亳舒仆 亠仆仂仍仂亞 class DetailViewCellDefault : UITableViewCell { let label = UITextView(editable: false, style: .Label) let data = UITextView(editable: false, style: .Text) var cellReuse = false func setInit() { contentView.addSubview(label) contentView.addSubview(data) contentView.leadingAnchor.constraintEqualToAnchor(label.leadingAnchor).active = true contentView.topAnchor.constraintEqualToAnchor(label.topAnchor).active = true contentView.trailingAnchor.constraintEqualToAnchor(label.trailingAnchor).active = true label.bottomAnchor.constraintEqualToAnchor(data.topAnchor).active = true contentView.leadingAnchor.constraintEqualToAnchor(data.leadingAnchor).active = true contentView.trailingAnchor.constraintEqualToAnchor(data.trailingAnchor).active = true data.bottomAnchor.constraintEqualToAnchor(contentView.bottomAnchor).active = true } func setConfig(label label: String?, text: String?) { self.label.text = label data.text = text if !cellReuse { setInit() cellReuse = true } }