Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Number of small changes/optimisations #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Example/Ohana/OHBasicContactPhotosPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class OHBasicContactPhotosPicker : UITableViewController, OHCNContactsDataProvid
dataSource = OHContactsDataSource(dataProviders: NSOrderedSet(objects: dataProvider), postProcessors: NSOrderedSet(object: alphabeticalSortProcessor))

dataSource.onContactsDataSourceReadySignal.addObserver(self, callback: { [weak self] (observer) in
self?.tableView?.reloadData()
DispatchQueue.main.async {
self?.tableView?.reloadData()
}
})

dataSource.loadContacts()
Expand Down
6 changes: 4 additions & 2 deletions Example/Ohana/OHBasicContactPickerTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ - (instancetype)init
postProcessors:[NSOrderedSet orderedSetWithObjects:alphabeticalSortProcessor, nil]];

[self.dataSource.onContactsDataSourceReadySignal addObserver:self callback:^(typeof(self) self, NSOrderedSet<OHContact *> * _Nonnull contacts) {
self.contactsByLetter = [self _contactsByLetterDictionaryForContacts:self.dataSource.contacts];
[self.tableView reloadData];
dispatch_async(dispatch_get_main_queue(), ^{
self.contactsByLetter = [self _contactsByLetterDictionaryForContacts:self.dataSource.contacts];
[self.tableView reloadData];
});
}];

[self.dataSource.onContactsDataSourceSelectedContactsSignal addObserver:self callback:^(typeof(self) self, NSOrderedSet<OHContact *> * _Nonnull selectedContacts) {
Expand Down
6 changes: 4 additions & 2 deletions Example/Ohana/OHContactSelectionTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ - (instancetype)init
postProcessors:[NSOrderedSet orderedSetWithObjects:alphabeticalSortProcessor, nil]];

[self.dataSource.onContactsDataSourceReadySignal addObserver:self callback:^(typeof(self) self, NSOrderedSet<OHContact *> * _Nonnull contacts) {
self.contactsByLetter = [self _contactsByLetterDictionaryForContacts:self.dataSource.contacts];
[self.tableView reloadData];
dispatch_async(dispatch_get_main_queue(), ^{
self.contactsByLetter = [self _contactsByLetterDictionaryForContacts:self.dataSource.contacts];
[self.tableView reloadData];
});
}];

[self.dataSource.onContactsDataSourceSelectedContactsSignal addObserver:self callback:^(typeof(self) self, NSOrderedSet<OHContact *> * _Nonnull selectedContacts) {
Expand Down
2 changes: 1 addition & 1 deletion Example/Ohana/OHFuzzySearchTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ - (instancetype)init
postProcessors:[NSOrderedSet orderedSetWithObjects:alphabeticalSortProcessor, splitOnPhoneProcessor, nil]];

[self.dataSource.onContactsDataSourceReadySignal addObserver:self callback:^(typeof(self) self, NSOrderedSet<OHContact *> * _Nonnull contacts) {
self.fuzzyMatchingUtility = [[OHFuzzyMatchingUtility alloc] initWithContacts:self.dataSource.contacts];
dispatch_async(dispatch_get_main_queue(), ^(){
self.fuzzyMatchingUtility = [[OHFuzzyMatchingUtility alloc] initWithContacts:self.dataSource.contacts];
[self.tableView reloadData];
});
}];
Expand Down
4 changes: 3 additions & 1 deletion Example/Ohana/OHPhoneNumberPickerTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ - (instancetype)init
postProcessors:[NSOrderedSet orderedSetWithObjects:alphabeticalSortProcessor, splitOnPhoneProcessor, nil]];

[self.dataSource.onContactsDataSourceReadySignal addObserver:self callback:^(typeof(self) self, NSOrderedSet<OHContact *> * _Nonnull contacts) {
[self.tableView reloadData];
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
}];

[self.dataSource.onContactsDataSourceSelectedContactsSignal addObserver:self callback:^(typeof(self) self, NSOrderedSet<OHContact *> * _Nonnull selectedContacts) {
Expand Down
2 changes: 1 addition & 1 deletion Example/Ohana/OHSMSPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class OHSMSPicker: UITableViewController, OHCNContactsDataProviderDelegate, OHAB
if let phoneNumber = contact.contactFields?.object(at: 0) as? OHContactField {
composer.recipients = [ phoneNumber.value ]
}
composer.messageComposeDelegate = self as? MFMessageComposeViewControllerDelegate
composer.messageComposeDelegate = self
self?.present(composer, animated: true, completion: nil)
} else {
let alertController = UIAlertController(title: "Unable to Send SMS", message: "Please run on a device that can send SMS messages.", preferredStyle: .alert)
Expand Down
1 change: 0 additions & 1 deletion Example/Tests/OHABAddressBookContactsDataProviderTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#import <XCTest/XCTest.h>
#import <Ohana/Ohana.h>
#import <OCMock/OCMock.h>

#import "NSOrderedSetMake+Internal.h"

Expand Down
1 change: 0 additions & 1 deletion Example/Tests/OHAlphabeticalSortPostProcessorTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#import <XCTest/XCTest.h>
#import <Ohana/Ohana.h>
#import <OCMock/OCMock.h>

#import "NSOrderedSetMake+Internal.h"

Expand Down
1 change: 0 additions & 1 deletion Example/Tests/OHCNContactsDataProviderTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#import <XCTest/XCTest.h>
#import <Ohana/Ohana.h>
#import <OCMock/OCMock.h>

@interface OHCNContactsDataProvider ()

Expand Down
2 changes: 2 additions & 0 deletions Example/Tests/OHContactTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ @implementation OHContactTests

- (void)setUp
{
[super setUp];

self.contact = [[OHContact alloc] init];
self.contact.fullName = @"Full Name";
self.contact.firstName = @"First";
Expand Down
6 changes: 0 additions & 6 deletions Example/Tests/OHPhoneNumberFormattingPostProcessorTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ @interface OHPhoneNumberFormattingPostProcessorTests : XCTestCase

@implementation OHPhoneNumberFormattingPostProcessorTests

- (void)setUp
{
[super setUp];


}

- (void)testFormatting
{
Expand Down
1 change: 0 additions & 1 deletion Example/Tests/OHRequiredFieldPostProcessorTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#import <XCTest/XCTest.h>
#import <Ohana/Ohana.h>
#import <OCMock/OCMock.h>

#import "NSOrderedSetMake+Internal.h"

Expand Down
1 change: 0 additions & 1 deletion Example/Tests/OHRequiredPostalAddressPostProcessorTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#import <XCTest/XCTest.h>
#import <Ohana/Ohana.h>
#import <OCMock/OCMock.h>

#import "NSOrderedSetMake+Internal.h"

Expand Down
1 change: 0 additions & 1 deletion Example/Tests/OHReverseOrderPostProcessorTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#import <XCTest/XCTest.h>
#import <Ohana/Ohana.h>
#import <OCMock/OCMock.h>

#import "NSOrderedSetMake+Internal.h"

Expand Down
1 change: 0 additions & 1 deletion Example/Tests/OHSplitOnFieldTypePostProcessorTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#import <XCTest/XCTest.h>
#import <Ohana/Ohana.h>
#import <OCMock/OCMock.h>

#import "NSOrderedSetMake+Internal.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ NS_CLASS_AVAILABLE_IOS(9_0)
NS_CLASS_AVAILABLE_IOS(9_0)
@interface OHCNContactsDataProvider : NSObject <OHContactsDataProviderProtocol>

extern NSString *_Nonnull kOHCNContactsDataProviderContactIdentifierKey; // Identifier unique among contacts on the device (NSString *)
extern NSString *kOHCNContactsDataProviderContactIdentifierKey; // Identifier unique among contacts on the device (NSString *)

/**
* By default, the data provider does not load a thumbnail image to conserve space. Set this to `YES` to load thumbnail image.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ typedef NS_OPTIONS (NSInteger, OHPhoneNumberFormat) {

@interface OHPhoneNumberFormattingPostProcessor : NSObject <OHContactsPostProcessorProtocol>

extern NSString *_Nonnull kOHFormattedPhoneNumberE164; // Phone number in E164 format (NSString *)
extern NSString *_Nonnull kOHFormattedPhoneNumberInternational; // Phone number in International format (NSString *)
extern NSString *_Nonnull kOHFormattedPhoneNumberNational; // Phone number in National format (NSString *)
extern NSString *_Nonnull kOHFormattedPhoneNumberRFC3966; // Phone number in RFC3966 format (NSString *)
extern NSString *kOHFormattedPhoneNumberE164; // Phone number in E164 format (NSString *)
extern NSString *kOHFormattedPhoneNumberInternational; // Phone number in International format (NSString *)
extern NSString *kOHFormattedPhoneNumberNational; // Phone number in National format (NSString *)
extern NSString *kOHFormattedPhoneNumberRFC3966; // Phone number in RFC3966 format (NSString *)

/**
* Bit mask of formats to use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ NS_ASSUME_NONNULL_BEGIN

@interface OHStatisticsPostProcessor : NSObject <OHContactsPostProcessorProtocol>

extern NSString *_Nonnull kOHStatisticsNumberOfContactFields; // Total number of contact fields (NSNumber)
extern NSString *_Nonnull kOHStatisticsNumberOfPhoneNumbers; // Number of contact fields of type UBContactFieldTypePhoneNumber (NSNumber *)
extern NSString *_Nonnull kOHStatisticsNumberOfEmailAddresses; // Number of contact fields of type UBContactFieldTypeEmailAddress (NSNumber *)
extern NSString *_Nonnull kOHStatisticsHasMobilePhoneNumber; // Whether or not contact has a phone number with label of type "mobile" or "iPhone" (NSNumber *)
extern NSString *kOHStatisticsNumberOfContactFields; // Total number of contact fields (NSNumber)
extern NSString *kOHStatisticsNumberOfPhoneNumbers; // Number of contact fields of type UBContactFieldTypePhoneNumber (NSNumber *)
extern NSString *kOHStatisticsNumberOfEmailAddresses; // Number of contact fields of type UBContactFieldTypeEmailAddress (NSNumber *)
extern NSString *kOHStatisticsHasMobilePhoneNumber; // Whether or not contact has a phone number with label of type "mobile" or "iPhone" (NSNumber *)

@end

Expand Down
2 changes: 1 addition & 1 deletion Ohana/Classes/Core/OHContactsDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ - (instancetype)initWithDataProviders:(NSOrderedSet<id<OHContactsDataProviderPro
_onContactsDataSourceDeselectedContactsSignal = [[OHContactsDataSourceDeselectedContactsSignal alloc] init];

_allContacts = [[NSMutableOrderedSet<OHContact *> alloc] init];
_selectedContacts = [[NSMutableOrderedSet alloc] init];
_selectedContacts = [[NSMutableOrderedSet<OHContact *> alloc] init];


_completedDataProviders = [[NSMutableSet<id<OHContactsDataProviderProtocol>> alloc] initWithCapacity:dataProviders.count];
Expand Down