Ran "Edit -> Refactor -> Convert to Modern Objective-C Syntax"

- dictionaryWithObject -> @{key: val}
- objectAtIndex -> a[i]
- numberWithBool/Int/etc -> @1, @(val)
- Reverted friendly fire on ProtocolBuffers
- Did not do ANY other changes (including changes to make more refactorings succeed)
//FREEBIE
pull/1/head
Craig Gidney 11 years ago committed by Frederic Jacobs
parent 6fd78ef143
commit 1e9a3e9a46

@ -66,7 +66,7 @@
NSError *error; NSError *error;
NSDictionary *attrs = [NSDictionary dictionaryWithObject:NSFileProtectionComplete forKey:NSFileProtectionKey]; NSDictionary *attrs = @{NSFileProtectionKey: NSFileProtectionComplete};
[[NSFileManager defaultManager] setAttributes:attrs ofItemAtPath:preferencesPath error:&error]; [[NSFileManager defaultManager] setAttributes:attrs ofItemAtPath:preferencesPath error:&error];
[pathsToExclude addObject:[[preferencesPath stringByAppendingString:[[NSBundle mainBundle] bundleIdentifier]] stringByAppendingString:@".plist"]]; [pathsToExclude addObject:[[preferencesPath stringByAppendingString:[[NSBundle mainBundle] bundleIdentifier]] stringByAppendingString:@".plist"]];
@ -74,15 +74,15 @@
NSString *logPath = [NSHomeDirectory() stringByAppendingString:@"/Library/Caches/Logs/"]; NSString *logPath = [NSHomeDirectory() stringByAppendingString:@"/Library/Caches/Logs/"];
NSArray *logsFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:logPath error:&error]; NSArray *logsFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:logPath error:&error];
attrs = [NSDictionary dictionaryWithObject:NSFileProtectionComplete forKey:NSFileProtectionKey]; attrs = @{NSFileProtectionKey: NSFileProtectionComplete};
[[NSFileManager defaultManager] setAttributes:attrs ofItemAtPath:logPath error:&error]; [[NSFileManager defaultManager] setAttributes:attrs ofItemAtPath:logPath error:&error];
for (NSUInteger i = 0; i < [logsFiles count]; i++) { for (NSUInteger i = 0; i < [logsFiles count]; i++) {
[pathsToExclude addObject:[logPath stringByAppendingString:[logsFiles objectAtIndex:i]]]; [pathsToExclude addObject:[logPath stringByAppendingString:logsFiles[i]]];
} }
for (NSUInteger i = 0; i < [pathsToExclude count]; i++) { for (NSUInteger i = 0; i < [pathsToExclude count]; i++) {
[[NSURL fileURLWithPath:[pathsToExclude objectAtIndex:i]] setResourceValue: [NSNumber numberWithBool: YES] [[NSURL fileURLWithPath:pathsToExclude[i]] setResourceValue: @YES
forKey: NSURLIsExcludedFromBackupKey error: &error]; forKey: NSURLIsExcludedFromBackupKey error: &error];
} }
@ -134,7 +134,7 @@
[self.window makeKeyAndVisible]; [self.window makeKeyAndVisible];
//Accept push notification when app is not open //Accept push notification when app is not open
NSDictionary *remoteNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; NSDictionary *remoteNotif = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
if (remoteNotif) { if (remoteNotif) {
DDLogInfo(@"Application was launched by tapping a push notification."); DDLogInfo(@"Application was launched by tapping a push notification.");
[self application:application didReceiveRemoteNotification:remoteNotif]; [self application:application didReceiveRemoteNotification:remoteNotif];

@ -42,7 +42,7 @@
// Uniquely Identify a notification by the hash of the message payload. // Uniquely Identify a notification by the hash of the message payload.
-(NSData*) getIdForNotification:(NSDictionary*) notification { -(NSData*) getIdForNotification:(NSDictionary*) notification {
NSData* data = [[notification objectForKey:NOTIFICATION_PAYLOAD_KEY] dataUsingEncoding:NSUTF8StringEncoding]; NSData* data = [notification[NOTIFICATION_PAYLOAD_KEY] dataUsingEncoding:NSUTF8StringEncoding];
NSData* notificationHash = [data hashWithSha256]; NSData* notificationHash = [data hashWithSha256];
return notificationHash; return notificationHash;
} }

@ -44,7 +44,7 @@ NSMutableDictionary* currentActiveAudioPlayers;
} }
-(void) stopSound:(SoundInstance*) sound { -(void) stopSound:(SoundInstance*) sound {
SoundInstance* playingSoundInstance = [currentActiveAudioPlayers objectForKey:[sound getId] ]; SoundInstance* playingSoundInstance = currentActiveAudioPlayers[[sound getId]];
[self removeSoundFromManifest:sound]; [self removeSoundFromManifest:sound];
[playingSoundInstance stop]; [playingSoundInstance stop];
} }
@ -56,7 +56,7 @@ NSMutableDictionary* currentActiveAudioPlayers;
} }
-(BOOL) isSoundPlaying:(SoundInstance*) sound { -(BOOL) isSoundPlaying:(SoundInstance*) sound {
return nil != [currentActiveAudioPlayers objectForKey:[sound getId]]; return nil != currentActiveAudioPlayers[[sound getId]];
} }
-(void) awake { -(void) awake {

@ -22,7 +22,7 @@
d->lateBins = [NSMutableArray array]; d->lateBins = [NSMutableArray array];
for (NSUInteger i = 0; i < PRIOR_LATENESS_LENGTH; i++) { for (NSUInteger i = 0; i < PRIOR_LATENESS_LENGTH; i++) {
[d->priorLatenesses enqueue:[NSNumber numberWithDouble:0]]; [d->priorLatenesses enqueue:@0.0];
} }
for (NSUInteger i = 0; i < LATE_BINS_LENGTH; i++) { for (NSUInteger i = 0; i < LATE_BINS_LENGTH; i++) {
[d->lateBins addObject:[EventWindow eventWindowWithWindowDuration:LATE_BIN_WINDOW_IN_SECONDS]]; [d->lateBins addObject:[EventWindow eventWindowWithWindowDuration:LATE_BIN_WINDOW_IN_SECONDS]];
@ -53,7 +53,7 @@
NSTimeInterval expectedTime = startTime + drift + expandedSequenceNumber * audioDurationPerPacket; NSTimeInterval expectedTime = startTime + drift + expandedSequenceNumber * audioDurationPerPacket;
NSTimeInterval now = [TimeUtil time]; NSTimeInterval now = [TimeUtil time];
NSTimeInterval secLate = now-expectedTime; NSTimeInterval secLate = now-expectedTime;
[priorLatenesses enqueue:[NSNumber numberWithDouble:secLate]]; [priorLatenesses enqueue:@(secLate)];
[priorLatenesses dequeue]; [priorLatenesses dequeue];
// update zero time // update zero time
@ -69,7 +69,7 @@
andMax:LATE_BINS_LENGTH - 1]; andMax:LATE_BINS_LENGTH - 1];
if (peakLatency <= maxActionableLatency) { if (peakLatency <= maxActionableLatency) {
[[lateBins objectAtIndex:lateBin] addEventAtTime:now]; [lateBins[lateBin] addEventAtTime:now];
} }
} }
@ -80,7 +80,7 @@
NSUInteger eventCount = 0; NSUInteger eventCount = 0;
NSTimeInterval now = [TimeUtil time]; NSTimeInterval now = [TimeUtil time];
for (NSUInteger depth = LATE_BINS_LENGTH; depth > 0; depth--) { for (NSUInteger depth = LATE_BINS_LENGTH; depth > 0; depth--) {
eventCount += [[lateBins objectAtIndex:depth-1] countAfterRemovingEventsBeforeWindowEndingAt:now]; eventCount += [lateBins[depth-1] countAfterRemovingEventsBeforeWindowEndingAt:now];
if (eventCount > maxEvents) { if (eventCount > maxEvents) {
return (depth-1)/binsPerPacket; return (depth-1)/binsPerPacket;
} }

@ -38,7 +38,7 @@ NSString *const CALL_TYPE_IMAGE_NAME_OUTGOING = @"outgoing_call_icon";
- (void)encodeWithCoder:(NSCoder *)encoder { - (void)encodeWithCoder:(NSCoder *)encoder {
[encoder encodeObject:[NSNumber numberWithInt:callType] forKey:DEFAULTS_KEY_CALL_TYPE]; [encoder encodeObject:[NSNumber numberWithInt:callType] forKey:DEFAULTS_KEY_CALL_TYPE];
[encoder encodeObject:phoneNumber forKey:DEFAULTS_KEY_PHONE_NUMBER]; [encoder encodeObject:phoneNumber forKey:DEFAULTS_KEY_PHONE_NUMBER];
[encoder encodeObject:[NSNumber numberWithInt:(int)contactRecordID] forKey:DEFAULTS_KEY_CONTACT_ID]; [encoder encodeObject:@((int)contactRecordID) forKey:DEFAULTS_KEY_CONTACT_ID];
[encoder encodeObject:date forKey:DEFAULTS_KEY_DATE]; [encoder encodeObject:date forKey:DEFAULTS_KEY_DATE];
[encoder encodeBool:isArchived forKey:DEFAULTS_KEY_IS_ARCHIVED]; [encoder encodeBool:isArchived forKey:DEFAULTS_KEY_IS_ARCHIVED];
[encoder encodeBool:userNotified forKey:DEFAULTS_KEY_USER_NOTIFIED]; [encoder encodeBool:userNotified forKey:DEFAULTS_KEY_USER_NOTIFIED];

@ -115,7 +115,7 @@ typedef BOOL (^SearchTermConditionalBlock)(RecentCall*, NSUInteger, BOOL*);
- (void)archiveRecentCall:(RecentCall *)recentCall { - (void)archiveRecentCall:(RecentCall *)recentCall {
NSUInteger indexOfRecent = [_allRecents indexOfObject:recentCall]; NSUInteger indexOfRecent = [_allRecents indexOfObject:recentCall];
recentCall.isArchived = YES; recentCall.isArchived = YES;
[_allRecents replaceObjectAtIndex:indexOfRecent withObject:recentCall]; _allRecents[indexOfRecent] = recentCall;
[self saveContactsToDefaults]; [self saveContactsToDefaults];
[observableRecentsController updateValue:[_allRecents copy]]; [observableRecentsController updateValue:[_allRecents copy]];
} }

@ -351,19 +351,19 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
+(NSDictionary *)keyContactsById:(NSArray *)contacts { +(NSDictionary *)keyContactsById:(NSArray *)contacts {
return [contacts keyedBy:^id(Contact* contact) { return [contacts keyedBy:^id(Contact* contact) {
return [NSNumber numberWithInt:(int)contact.recordID]; return @((int)contact.recordID);
}]; }];
} }
-(Contact *)latestContactWithRecordId:(ABRecordID)recordId { -(Contact *)latestContactWithRecordId:(ABRecordID)recordId {
@synchronized(self) { @synchronized(self) {
return [latestContactsById objectForKey:[NSNumber numberWithInt:recordId]]; return latestContactsById[@(recordId)];
} }
} }
-(NSArray*) recordsForContacts:(NSArray*) contacts{ -(NSArray*) recordsForContacts:(NSArray*) contacts{
return [contacts map:^id(Contact *contact) { return [contacts map:^id(Contact *contact) {
return [NSNumber numberWithInt:[contact recordID]]; return @([contact recordID]);
}]; }];
} }
@ -423,7 +423,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
contact.isFavourite = !contact.isFavourite; contact.isFavourite = !contact.isFavourite;
if (contact.isFavourite) { if (contact.isFavourite) {
[_favouriteContactIds addObject:[NSNumber numberWithInt:contact.recordID]]; [_favouriteContactIds addObject:@(contact.recordID)];
} else { } else {
ContactSearchBlock removeBlock = ^BOOL(NSNumber *favouriteNumber, NSUInteger idx, BOOL *stop) { ContactSearchBlock removeBlock = ^BOOL(NSNumber *favouriteNumber, NSUInteger idx, BOOL *stop) {
@ -461,7 +461,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
if(!newUserNotificationsEnabled){ if(!newUserNotificationsEnabled){
[self addContactsToKnownWhisperUsers:unacknowledgedUsers]; [self addContactsToKnownWhisperUsers:unacknowledgedUsers];
}else{ }else{
NSDictionary *payload = [NSDictionary dictionaryWithObject:unacknowledgedUsers forKey:NOTIFICATION_DATAKEY_NEW_USERS]; NSDictionary *payload = @{NOTIFICATION_DATAKEY_NEW_USERS: unacknowledgedUsers};
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_NEW_USERS_AVAILABLE object:self userInfo:payload]; [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_NEW_USERS_AVAILABLE object:self userInfo:payload];
} }
} }
@ -534,7 +534,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
} }
-(void) clearKnownWhisUsers{ -(void) clearKnownWhisUsers{
[[NSUserDefaults standardUserDefaults] setObject:[NSArray array] forKey:KNOWN_USERS_DEFAULT_KEY]; [[NSUserDefaults standardUserDefaults] setObject:@[] forKey:KNOWN_USERS_DEFAULT_KEY];
[[NSUserDefaults standardUserDefaults] synchronize]; [[NSUserDefaults standardUserDefaults] synchronize];
} }

@ -23,7 +23,7 @@
+(NSString*) computeOtpWithPassword:(NSString*)password andCounter:(int64_t)counter { +(NSString*) computeOtpWithPassword:(NSString*)password andCounter:(int64_t)counter {
require(password != nil); require(password != nil);
NSData* d = [[[NSNumber numberWithLongLong:counter] stringValue] encodedAsUtf8]; NSData* d = [[@(counter) stringValue] encodedAsUtf8];
NSData* h = [d hmacWithSha1WithKey:[password encodedAsUtf8]]; NSData* h = [d hmacWithSha1WithKey:[password encodedAsUtf8]];
return [h encodedAsBase64]; return [h encodedAsBase64];
} }

@ -51,7 +51,7 @@ MacrosSingletonImplemention
NSArray *logsFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:logPath error:&error]; NSArray *logsFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:logPath error:&error];
for (NSUInteger i = 0; i < [logsFiles count]; i++) { for (NSUInteger i = 0; i < [logsFiles count]; i++) {
[[NSFileManager defaultManager] removeItemAtPath:[logPath stringByAppendingString:[logsFiles objectAtIndex:i]] error:&error]; [[NSFileManager defaultManager] removeItemAtPath:[logPath stringByAppendingString:logsFiles[i]] error:&error];
} }
if (error) { if (error) {

@ -44,7 +44,7 @@
if (phoneNumberDirectoryFilter == nil) return; if (phoneNumberDirectoryFilter == nil) return;
NSData* data = [[phoneNumberDirectoryFilter bloomFilter] data]; NSData* data = [[phoneNumberDirectoryFilter bloomFilter] data];
NSNumber* hashCount = [NSNumber numberWithUnsignedInteger:[[phoneNumberDirectoryFilter bloomFilter] hashCount]]; NSNumber* hashCount = @([[phoneNumberDirectoryFilter bloomFilter] hashCount]);
NSDate* expiry = [phoneNumberDirectoryFilter getExpirationDate]; NSDate* expiry = [phoneNumberDirectoryFilter getExpirationDate];
[self setValueForKey:PHONE_DIRECTORY_BLOOM_FILTER_DATA_KEY toValue:data]; [self setValueForKey:PHONE_DIRECTORY_BLOOM_FILTER_DATA_KEY toValue:data];
[self setValueForKey:PHONE_DIRECTORY_BLOOM_FILTER_HASH_COUNT_KEY toValue:hashCount]; [self setValueForKey:PHONE_DIRECTORY_BLOOM_FILTER_HASH_COUNT_KEY toValue:hashCount];
@ -63,7 +63,7 @@
} }
-(void) setCachedDesiredBufferDepth:(double)value { -(void) setCachedDesiredBufferDepth:(double)value {
require(value >= 0); require(value >= 0);
[self setValueForKey:CALL_STREAM_DES_BUFFER_LEVEL_KEY toValue:[NSNumber numberWithDouble:value]]; [self setValueForKey:CALL_STREAM_DES_BUFFER_LEVEL_KEY toValue:@(value)];
} }
-(BOOL) getFreshInstallTutorialsEnabled { -(BOOL) getFreshInstallTutorialsEnabled {
@ -118,32 +118,32 @@
} }
-(void)setScreenSecurity:(BOOL)flag{ -(void)setScreenSecurity:(BOOL)flag{
[self setValueForKey:SCREEN_SECURITY_KEY toValue:[NSNumber numberWithBool:flag]]; [self setValueForKey:SCREEN_SECURITY_KEY toValue:@(flag)];
} }
-(void) setFreshInstallTutorialsEnabled:(BOOL)enabled { -(void) setFreshInstallTutorialsEnabled:(BOOL)enabled {
[self setValueForKey:FRESH_INSTALL_TUTORIALS_ENABLED_KEY toValue:[NSNumber numberWithBool:enabled]]; [self setValueForKey:FRESH_INSTALL_TUTORIALS_ENABLED_KEY toValue:@(enabled)];
} }
-(void) setContactImagesEnabled:(BOOL)enabled { -(void) setContactImagesEnabled:(BOOL)enabled {
[self setValueForKey:CONTACT_IMAGES_ENABLED_KEY toValue:[NSNumber numberWithBool:enabled]]; [self setValueForKey:CONTACT_IMAGES_ENABLED_KEY toValue:@(enabled)];
} }
-(void) setAutocorrectEnabled:(BOOL)enabled { -(void) setAutocorrectEnabled:(BOOL)enabled {
[self setValueForKey:AUTOCORRECT_ENABLED_KEY toValue:[NSNumber numberWithBool:enabled]]; [self setValueForKey:AUTOCORRECT_ENABLED_KEY toValue:@(enabled)];
} }
-(void) setHistoryLogEnabled:(BOOL)enabled { -(void) setHistoryLogEnabled:(BOOL)enabled {
[self setValueForKey:HISTORY_LOG_ENABLED_KEY toValue:[NSNumber numberWithBool:enabled]]; [self setValueForKey:HISTORY_LOG_ENABLED_KEY toValue:@(enabled)];
} }
-(BOOL) encounteredRevokedPushPermission{ -(BOOL) encounteredRevokedPushPermission{
return [[self tryGetValueForKey:PUSH_REVOKED_KEY] boolValue]; return [[self tryGetValueForKey:PUSH_REVOKED_KEY] boolValue];
} }
-(void) setRevokedPushPermission:(BOOL)revoked{ -(void) setRevokedPushPermission:(BOOL)revoked{
[self setValueForKey:PUSH_REVOKED_KEY toValue:[NSNumber numberWithBool:revoked]]; [self setValueForKey:PUSH_REVOKED_KEY toValue:@(revoked)];
} }
-(void) setLoggingEnabled:(BOOL)flag{ -(void) setLoggingEnabled:(BOOL)flag{
[self setValueForKey:DEBUG_IS_ENABLED_KEY toValue:[NSNumber numberWithBool:flag]]; [self setValueForKey:DEBUG_IS_ENABLED_KEY toValue:@(flag)];
} }
-(NSString*)lastRanVersion{ -(NSString*)lastRanVersion{
@ -153,7 +153,7 @@
-(NSString*)setAndGetCurrentVersion{ -(NSString*)setAndGetCurrentVersion{
NSString *lastVersion = [self lastRanVersion]; NSString *lastVersion = [self lastRanVersion];
[[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithFormat:@"%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]] forKey:kSignalVersionKey]; [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithFormat:@"%@", [[NSBundle mainBundle] infoDictionary][@"CFBundleVersion"]] forKey:kSignalVersionKey];
[[NSUserDefaults standardUserDefaults] synchronize]; [[NSUserDefaults standardUserDefaults] synchronize];
return lastVersion; return lastVersion;
} }

@ -46,7 +46,7 @@
__block int64_t oldCounter; __block int64_t oldCounter;
oldCounter = [[UICKeyChainStore stringForKey:PASSWORD_COUNTER_KEY] longLongValue]; oldCounter = [[UICKeyChainStore stringForKey:PASSWORD_COUNTER_KEY] longLongValue];
int64_t newCounter = (oldCounter == INT64_MAX)?INT64_MIN:(oldCounter + 1); int64_t newCounter = (oldCounter == INT64_MAX)?INT64_MIN:(oldCounter + 1);
[self storeString:[[NSNumber numberWithLongLong:newCounter] stringValue] forKey:PASSWORD_COUNTER_KEY]; [self storeString:[@(newCounter) stringValue] forKey:PASSWORD_COUNTER_KEY];
return newCounter; return newCounter;
} }

@ -29,8 +29,8 @@
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
for (NSUInteger i = 0; i < [entries count]; i++) { for (NSUInteger i = 0; i < [entries count]; i++) {
NSString *key = [entries objectAtIndex:i]; NSString *key = entries[i];
[defaults setObject:[dict objectForKey:key] forKey:key]; [defaults setObject:dict[key] forKey:key];
} }
[defaults synchronize]; [defaults synchronize];

@ -126,13 +126,13 @@
char buffer[INET_ADDRSTRLEN]; char buffer[INET_ADDRSTRLEN];
const char* result = inet_ntop(AF_INET, &addr->sin_addr, buffer, INET_ADDRSTRLEN); const char* result = inet_ntop(AF_INET, &addr->sin_addr, buffer, INET_ADDRSTRLEN);
checkOperationDescribe(result != NULL, @"Invalid ipv4 address data"); checkOperationDescribe(result != NULL, @"Invalid ipv4 address data");
return [NSString stringWithUTF8String:result]; return @(result);
} }
+(NSString*) ipv6AddressToString:(const struct sockaddr_in6*)addr { +(NSString*) ipv6AddressToString:(const struct sockaddr_in6*)addr {
char buffer[INET6_ADDRSTRLEN]; char buffer[INET6_ADDRSTRLEN];
const char* result = inet_ntop(AF_INET6, &addr->sin6_addr, buffer, INET6_ADDRSTRLEN); const char* result = inet_ntop(AF_INET6, &addr->sin6_addr, buffer, INET6_ADDRSTRLEN);
checkOperationDescribe(result != NULL, @"Invalid ipv6 address data"); checkOperationDescribe(result != NULL, @"Invalid ipv6 address data");
return [NSString stringWithUTF8String:result]; return @(result);
} }
@end @end

@ -18,8 +18,8 @@
require(method != nil); require(method != nil);
require(location != nil); require(location != nil);
require(headers != nil); require(headers != nil);
require((optionalBody == nil) == ([headers objectForKey:@"Content-Length"] == nil)); require((optionalBody == nil) == (headers[@"Content-Length"] == nil));
require(optionalBody == nil || [[[NSNumber numberWithUnsignedInteger:[optionalBody length]] description] isEqualToString:[headers objectForKey:@"Content-Length"]]); require(optionalBody == nil || [[@([optionalBody length]) description] isEqualToString:headers[@"Content-Length"]]);
HttpRequest* s = [HttpRequest new]; HttpRequest* s = [HttpRequest new];
s->_method = method; s->_method = method;
@ -36,7 +36,7 @@
NSMutableDictionary* headers = [NSMutableDictionary dictionary]; NSMutableDictionary* headers = [NSMutableDictionary dictionary];
if (optionalBody != nil) { if (optionalBody != nil) {
[headers setObject:[[NSNumber numberWithUnsignedInteger:[optionalBody length]] stringValue] forKey:@"Content-Length"]; headers[@"Content-Length"] = [@([optionalBody length]) stringValue];
} }
HttpRequest* s = [HttpRequest new]; HttpRequest* s = [HttpRequest new];
@ -58,9 +58,9 @@
NSMutableDictionary* headers = [NSMutableDictionary dictionary]; NSMutableDictionary* headers = [NSMutableDictionary dictionary];
if (optionalBody != nil) { if (optionalBody != nil) {
[headers setObject:[[NSNumber numberWithUnsignedInteger:[optionalBody length]] stringValue] forKey:@"Content-Length"]; headers[@"Content-Length"] = [@([optionalBody length]) stringValue];
} }
[headers setObject:[HttpRequest computeBasicAuthorizationTokenForLocalNumber:localNumber andPassword:password] forKey:@"Authorization"]; headers[@"Authorization"] = [HttpRequest computeBasicAuthorizationTokenForLocalNumber:localNumber andPassword:password];
HttpRequest* s = [HttpRequest new]; HttpRequest* s = [HttpRequest new];
s->_method = method; s->_method = method;
@ -81,9 +81,9 @@
NSMutableDictionary* headers = [NSMutableDictionary dictionary]; NSMutableDictionary* headers = [NSMutableDictionary dictionary];
if (optionalBody != nil) { if (optionalBody != nil) {
[headers setObject:[[NSNumber numberWithUnsignedInteger:[optionalBody length]] stringValue] forKey:@"Content-Length"]; headers[@"Content-Length"] = [@([optionalBody length]) stringValue];
} }
[headers setObject:[HttpRequest computeOtpAuthorizationTokenForLocalNumber:localNumber andCounterValue:counter andPassword:password] forKey:@"Authorization"]; headers[@"Authorization"] = [HttpRequest computeOtpAuthorizationTokenForLocalNumber:localNumber andCounterValue:counter andPassword:password];
HttpRequest* s = [HttpRequest new]; HttpRequest* s = [HttpRequest new];
s->_method = method; s->_method = method;
@ -131,7 +131,7 @@
for (NSString* key in self.headers) { for (NSString* key in self.headers) {
[r addObject:key]; [r addObject:key];
[r addObject:@": "]; [r addObject:@": "];
[r addObject:[self.headers objectForKey:key]]; [r addObject:(self.headers)[key]];
[r addObject:@"\r\n"]; [r addObject:@"\r\n"];
} }

@ -49,25 +49,25 @@
// GET /index.html HTTP/1.1 // GET /index.html HTTP/1.1
// HTTP/1.1 200 OK // HTTP/1.1 200 OK
NSString* requestOrResponseLine = [headerLines objectAtIndex:0]; NSString* requestOrResponseLine = headerLines[0];
NSArray* requestOrResponseLineParts = [requestOrResponseLine componentsSeparatedByString:@" "]; NSArray* requestOrResponseLineParts = [requestOrResponseLine componentsSeparatedByString:@" "];
checkOperation([requestOrResponseLineParts count] >= 3); checkOperation([requestOrResponseLineParts count] >= 3);
bool isResponse = [[requestOrResponseLineParts objectAtIndex:0] hasPrefix:@"HTTP/"]; bool isResponse = [requestOrResponseLineParts[0] hasPrefix:@"HTTP/"];
// Host: www.example.com // Host: www.example.com
// Content-Length: 5 // Content-Length: 5
NSMutableDictionary* headers = [NSMutableDictionary dictionary]; NSMutableDictionary* headers = [NSMutableDictionary dictionary];
for (NSUInteger i = 1; i < [headerLines count]; i++) { for (NSUInteger i = 1; i < [headerLines count]; i++) {
NSString* headerLine = [headerLines objectAtIndex:i]; NSString* headerLine = headerLines[i];
NSArray* headerLineParts = [headerLine componentsSeparatedByString:@":"]; NSArray* headerLineParts = [headerLine componentsSeparatedByString:@":"];
checkOperation([headerLineParts count] >= 2); checkOperation([headerLineParts count] >= 2);
NSString* headerKey = [[headerLineParts objectAtIndex:0] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; NSString* headerKey = [headerLineParts[0] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString* headerValue = [[headerLine substringFromIndex:[(NSString *)[headerLineParts objectAtIndex:0] length]+1] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; NSString* headerValue = [[headerLine substringFromIndex:[(NSString *)headerLineParts[0] length]+1] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
[headers setObject:headerValue forKey:headerKey]; headers[headerKey] = headerValue;
} }
NSString* contextLengthText = [headers objectForKey:@"Content-Length"]; NSString* contextLengthText = headers[@"Content-Length"];
NSNumber* contentLengthParsed = [contextLengthText tryParseAsUnsignedInteger]; NSNumber* contentLengthParsed = [contextLengthText tryParseAsUnsignedInteger];
checkOperation((contextLengthText == nil) == (contentLengthParsed == nil)); checkOperation((contextLengthText == nil) == (contentLengthParsed == nil));
@ -78,7 +78,7 @@
*usedLengthPtr = headerLength + contentLength; *usedLengthPtr = headerLength + contentLength;
if (isResponse) { if (isResponse) {
NSNumber* statusCodeParsed = [[requestOrResponseLineParts objectAtIndex:1] tryParseAsUnsignedInteger]; NSNumber* statusCodeParsed = [requestOrResponseLineParts[1] tryParseAsUnsignedInteger];
checkOperation(statusCodeParsed != nil); checkOperation(statusCodeParsed != nil);
NSUInteger statusCode = [statusCodeParsed unsignedIntegerValue]; NSUInteger statusCode = [statusCodeParsed unsignedIntegerValue];
@ -90,8 +90,8 @@
return [HttpRequestOrResponse httpRequestOrResponse:response]; return [HttpRequestOrResponse httpRequestOrResponse:response];
} else { } else {
checkOperation([requestOrResponseLineParts count] == 3); checkOperation([requestOrResponseLineParts count] == 3);
NSString* method = [requestOrResponseLineParts objectAtIndex:0]; NSString* method = requestOrResponseLineParts[0];
NSString* location = [requestOrResponseLineParts objectAtIndex:1]; NSString* location = requestOrResponseLineParts[1];
HttpRequest* request = [HttpRequest httpRequestWithMethod:method HttpRequest* request = [HttpRequest httpRequestWithMethod:method
andLocation:location andLocation:location
andHeaders:headers andHeaders:headers

@ -62,7 +62,7 @@
+(HttpResponse*) httpResponse200OkWithOptionalBody:(NSString*)optionalBody { +(HttpResponse*) httpResponse200OkWithOptionalBody:(NSString*)optionalBody {
return [HttpResponse httpResponseFromStatusCode:200 return [HttpResponse httpResponseFromStatusCode:200
andStatusText:@"OK" andStatusText:@"OK"
andHeaders:[NSDictionary dictionary] andHeaders:@{}
andOptionalBodyText:optionalBody]; andOptionalBodyText:optionalBody];
} }
-(bool) isOkResponse { -(bool) isOkResponse {
@ -98,7 +98,7 @@
NSMutableArray* r = [NSMutableArray array]; NSMutableArray* r = [NSMutableArray array];
[r addObject:@"HTTP/1.0 "]; [r addObject:@"HTTP/1.0 "];
[r addObject:[[NSNumber numberWithUnsignedInteger:statusCode] description]]; [r addObject:[@(statusCode) description]];
[r addObject:@" "]; [r addObject:@" "];
[r addObject:statusText]; [r addObject:statusText];
[r addObject:@"\r\n"]; [r addObject:@"\r\n"];
@ -106,7 +106,7 @@
NSString* body = [self getOptionalBodyText]; NSString* body = [self getOptionalBodyText];
if (body != nil) { if (body != nil) {
[r addObject:@"Content-Length: "]; [r addObject:@"Content-Length: "];
[r addObject:[[NSNumber numberWithUnsignedInteger:[body length]] stringValue]]; [r addObject:[@([body length]) stringValue]];
[r addObject:@"\r\n"]; [r addObject:@"\r\n"];
[r addObject:body]; [r addObject:body];
} else { } else {

@ -46,7 +46,7 @@ const uint8_t PACKET_VERSION = 2;
require(payload != nil); require(payload != nil);
return [RtpPacket rtpPacketWithVersion:PACKET_VERSION return [RtpPacket rtpPacketWithVersion:PACKET_VERSION
andPadding:0 andPadding:0
andContributingSourceIdentifiers:[NSArray array] andContributingSourceIdentifiers:@[]
andSynchronizationSourceIdentifier:0 andSynchronizationSourceIdentifier:0
andMarkerBit:false andMarkerBit:false
andPayloadtype:0 andPayloadtype:0

@ -84,8 +84,8 @@ const char* PGP_LIST_ODD[] = {
uint8_t wordIndexTwo = [sasBytes uint8At:1]; uint8_t wordIndexTwo = [sasBytes uint8At:1];
return [NSString stringWithFormat:@"%@ %@", return [NSString stringWithFormat:@"%@ %@",
[NSString stringWithUTF8String:PGP_LIST_EVEN[wordIndexOne]], @(PGP_LIST_EVEN[wordIndexOne]),
[NSString stringWithUTF8String:PGP_LIST_ODD[wordIndexTwo]]]; @(PGP_LIST_ODD[wordIndexTwo])];
} }
@end @end

@ -123,7 +123,7 @@
NSData* extensionDataWithZeroCrc = [(@[payloadExceptCrc, [NSData dataWithBigEndianBytesOfUInt32:0]]) concatDatas]; NSData* extensionDataWithZeroCrc = [(@[payloadExceptCrc, [NSData dataWithBigEndianBytesOfUInt32:0]]) concatDatas];
RtpPacket* packetWithZeroCrc = [RtpPacket rtpPacketWithVersion:0 // invalid version 0 indicates a zrtp handshake packet RtpPacket* packetWithZeroCrc = [RtpPacket rtpPacketWithVersion:0 // invalid version 0 indicates a zrtp handshake packet
andPadding:false andPadding:false
andContributingSourceIdentifiers:[NSArray array] andContributingSourceIdentifiers:@[]
andSynchronizationSourceIdentifier:0 andSynchronizationSourceIdentifier:0
andExtensionIdentifier:HANDSHAKE_PACKET_EXTENSION_IDENTIFIER andExtensionIdentifier:HANDSHAKE_PACKET_EXTENSION_IDENTIFIER
andExtensionData:extensionDataWithZeroCrc andExtensionData:extensionDataWithZeroCrc
@ -138,7 +138,7 @@
return [RtpPacket rtpPacketWithVersion:0 // invalid version 0 indicates a zrtp handshake packet return [RtpPacket rtpPacketWithVersion:0 // invalid version 0 indicates a zrtp handshake packet
andPadding:false andPadding:false
andContributingSourceIdentifiers:[NSArray array] andContributingSourceIdentifiers:@[]
andSynchronizationSourceIdentifier:0 andSynchronizationSourceIdentifier:0
andExtensionIdentifier:HANDSHAKE_PACKET_EXTENSION_IDENTIFIER andExtensionIdentifier:HANDSHAKE_PACKET_EXTENSION_IDENTIFIER
andExtensionData:extensionData andExtensionData:extensionData

@ -67,11 +67,11 @@
andFlags0SMP:0 andFlags0SMP:0
andFlagsUnusedLow4:0 andFlagsUnusedLow4:0
andFlagsUnusedHigh4:0 andFlagsUnusedHigh4:0
andHashSpecIds:[NSArray array] andHashSpecIds:@[]
andCipherSpecIds:[NSArray array] andCipherSpecIds:@[]
andAuthSpecIds:[NSArray array] andAuthSpecIds:@[]
andAgreeSpecIds:[self getAgreeIdsFromKeyAgreementProtocols:keyAgreementProtocols] andAgreeSpecIds:[self getAgreeIdsFromKeyAgreementProtocols:keyAgreementProtocols]
andSasSpecIds:[NSArray array] andSasSpecIds:@[]
authenticatedWithHmacKey:[hashChain h2]]; authenticatedWithHmacKey:[hashChain h2]];
} }
@ -212,11 +212,11 @@
[NSNumber numberWithUnsignedInteger:sasIdsCount]]; [NSNumber numberWithUnsignedInteger:sasIdsCount]];
NSArray* specIds = [HelloPacket getSpecIdsFromPayload:payload counts:counts]; NSArray* specIds = [HelloPacket getSpecIdsFromPayload:payload counts:counts];
hashIds = [specIds objectAtIndex:HASH_IDS_INDEX]; hashIds = specIds[HASH_IDS_INDEX];
cipherIds = [specIds objectAtIndex:CIPHER_IDS_INDEX]; cipherIds = specIds[CIPHER_IDS_INDEX];
authIds = [specIds objectAtIndex:AUTH_IDS_INDEX]; authIds = specIds[AUTH_IDS_INDEX];
agreeIds = [specIds objectAtIndex:AGREE_IDS_INDEX]; agreeIds = specIds[AGREE_IDS_INDEX];
sasIds = [specIds objectAtIndex:SAS_IDS_INDEX]; sasIds = specIds[SAS_IDS_INDEX];
} }
+(HelloPacket*) helloPacketParsedFromHandshakePacket:(HandshakePacket*)handshakePacket { +(HelloPacket*) helloPacketParsedFromHandshakePacket:(HandshakePacket*)handshakePacket {
require(handshakePacket != nil); require(handshakePacket != nil);

@ -45,10 +45,8 @@
[[streamPair outputStream] setProperty:NSStreamSocketSecurityLevelNegotiatedSSL [[streamPair outputStream] setProperty:NSStreamSocketSecurityLevelNegotiatedSSL
forKey:NSStreamSocketSecurityLevelKey]; forKey:NSStreamSocketSecurityLevelKey];
NSDictionary *settings = [[NSDictionary alloc] initWithObjectsAndKeys: NSDictionary *settings = @{(id)kCFStreamSSLValidatesCertificateChain: @NO,
[NSNumber numberWithBool:NO], kCFStreamSSLValidatesCertificateChain, (id)kCFStreamSSLPeerName: hostNameEndPoint.hostname};
hostNameEndPoint.hostname, kCFStreamSSLPeerName,
nil];
CFReadStreamSetProperty((CFReadStreamRef)[streamPair inputStream], CFReadStreamSetProperty((CFReadStreamRef)[streamPair inputStream],
kCFStreamPropertySSLSettings, kCFStreamPropertySSLSettings,

@ -74,7 +74,7 @@ static NSString *const RPDefaultsKeyPhoneNumberCanonical = @"RPDefaultsKeyPhoneN
+(NSString*) regionCodeFromCountryCodeString:(NSString*) countryCodeString { +(NSString*) regionCodeFromCountryCodeString:(NSString*) countryCodeString {
NBPhoneNumberUtil* phoneUtil = [NBPhoneNumberUtil sharedInstance]; NBPhoneNumberUtil* phoneUtil = [NBPhoneNumberUtil sharedInstance];
NSString* regionCode = [phoneUtil getRegionCodeForCountryCode:[NSNumber numberWithInteger:[[countryCodeString substringFromIndex:1] integerValue]]]; NSString* regionCode = [phoneUtil getRegionCodeForCountryCode:@([[countryCodeString substringFromIndex:1] integerValue])];
return regionCode; return regionCode;
} }

@ -126,7 +126,7 @@
Future* futureEndPoint = [futureDnsResult then:^(NSArray* ipAddresses) { Future* futureEndPoint = [futureDnsResult then:^(NSArray* ipAddresses) {
require([ipAddresses count] > 0); require([ipAddresses count] > 0);
IpAddress* address = [ipAddresses objectAtIndex:arc4random_uniform((unsigned int)[ipAddresses count])]; IpAddress* address = ipAddresses[arc4random_uniform((unsigned int)[ipAddresses count])];
return [IpEndPoint ipEndPointAtAddress:address return [IpEndPoint ipEndPointAtAddress:address
onPort:sessionDescriptor.relayUdpPort]; onPort:sessionDescriptor.relayUdpPort];
}]; }];

@ -25,9 +25,9 @@
checkOperation(json != nil); checkOperation(json != nil);
NSDictionary* fields = [json decodedAsJsonIntoDictionary]; NSDictionary* fields = [json decodedAsJsonIntoDictionary];
id jsonSessionId = [fields objectForKey:SessionIdKey]; id jsonSessionId = fields[SessionIdKey];
id jsonRelayPort = [fields objectForKey:RelayPortKey]; id jsonRelayPort = fields[RelayPortKey];
id jsonRelayName = [fields objectForKey:RelayHostKey]; id jsonRelayName = fields[RelayHostKey];
checkOperationDescribe([jsonSessionId isKindOfClass:[NSNumber class]], @"Unexpected json data"); checkOperationDescribe([jsonSessionId isKindOfClass:[NSNumber class]], @"Unexpected json data");
checkOperationDescribe([jsonRelayPort isKindOfClass:[NSNumber class]], @"Unexpected json data"); checkOperationDescribe([jsonRelayPort isKindOfClass:[NSNumber class]], @"Unexpected json data");
checkOperationDescribe([jsonRelayName isKindOfClass:[NSString class]], @"Unexpected json data"); checkOperationDescribe([jsonRelayName isKindOfClass:[NSString class]], @"Unexpected json data");
@ -41,8 +41,8 @@
} }
-(NSString*) toJson { -(NSString*) toJson {
return [@{SessionIdKey : [NSNumber numberWithLongLong:sessionId], return [@{SessionIdKey : @(sessionId),
RelayPortKey : [NSNumber numberWithUnsignedShort:relayUdpPort], RelayPortKey : @(relayUdpPort),
RelayHostKey : relayServerName RelayHostKey : relayServerName
} encodedAsJson]; } encodedAsJson];
} }

@ -50,7 +50,7 @@
+(ResponderSessionDescriptor*)responderSessionDescriptorFromEncryptedRemoteNotification:(NSDictionary*)remoteNotif { +(ResponderSessionDescriptor*)responderSessionDescriptorFromEncryptedRemoteNotification:(NSDictionary*)remoteNotif {
require(remoteNotif != nil); require(remoteNotif != nil);
NSString* message = [remoteNotif objectForKey:MessagePropertyKey]; NSString* message = remoteNotif[MessagePropertyKey];
checkOperation(message != nil); checkOperation(message != nil);
NSData* authenticatedPayload = [message decodedAsBase64Data]; NSData* authenticatedPayload = [message decodedAsBase64Data];

@ -32,15 +32,15 @@
} }
-(bool) isRingingForSession:(int64_t)targetSessionId { -(bool) isRingingForSession:(int64_t)targetSessionId {
return [self.method isEqualToString:@"RING"] && [[NSNumber numberWithLongLong:targetSessionId] isEqualToNumber:[self tryGetSessionId]]; return [self.method isEqualToString:@"RING"] && [@(targetSessionId) isEqualToNumber:[self tryGetSessionId]];
} }
-(bool) isHangupForSession:(int64_t)targetSessionId { -(bool) isHangupForSession:(int64_t)targetSessionId {
return [self.method isEqualToString:@"DELETE"] && [[NSNumber numberWithLongLong:targetSessionId] isEqualToNumber:[self tryGetSessionId]]; return [self.method isEqualToString:@"DELETE"] && [@(targetSessionId) isEqualToNumber:[self tryGetSessionId]];
} }
-(bool) isBusyForSession:(int64_t)targetSessionId { -(bool) isBusyForSession:(int64_t)targetSessionId {
return [self.method isEqualToString:@"BUSY"] && [[NSNumber numberWithLongLong:targetSessionId] isEqualToNumber:[self tryGetSessionId]]; return [self.method isEqualToString:@"BUSY"] && [@(targetSessionId) isEqualToNumber:[self tryGetSessionId]];
} }
+(HttpRequest*) httpRequestToOpenPortWithSessionId:(int64_t)sessionId { +(HttpRequest*) httpRequestToOpenPortWithSessionId:(int64_t)sessionId {

@ -37,7 +37,7 @@
checkOperation([response isOkResponse]); checkOperation([response isOkResponse]);
NSString* hashCountHeader = [[response getHeaders] objectForKey:HASH_COUNT_HEADER_KEY]; NSString* hashCountHeader = [response getHeaders][HASH_COUNT_HEADER_KEY];
checkOperation(hashCountHeader != nil); checkOperation(hashCountHeader != nil);
int hashCountValue = [hashCountHeader intValue]; int hashCountValue = [hashCountHeader intValue];

@ -17,10 +17,10 @@
} }
-(void) log:(NSString*)category details:(id)details { -(void) log:(NSString*)category details:(id)details {
NSNumber* index = [indexDic objectForKey:category]; NSNumber* index = indexDic[category];
if (index == nil) { if (index == nil) {
index = [NSNumber numberWithUnsignedInteger:[indexDic count]]; index = @([indexDic count]);
[indexDic setObject:index forKey:category]; indexDic[category] = index;
} }
NSUInteger x = [index unsignedIntegerValue]; NSUInteger x = [index unsignedIntegerValue];
for (void (^callback)(NSString* category, id details, NSUInteger index) in callbacks) { for (void (^callback)(NSString* category, id details, NSUInteger index) in callbacks) {
@ -30,7 +30,7 @@
-(id<ValueLogger>) getValueLoggerForValue:(id)valueIdentity from:(id)sender { -(id<ValueLogger>) getValueLoggerForValue:(id)valueIdentity from:(id)sender {
id<ValueLogger> r = [AnonymousValueLogger anonymousValueLogger:^(double value) { id<ValueLogger> r = [AnonymousValueLogger anonymousValueLogger:^(double value) {
[self log:[NSString stringWithFormat:@"Value %@ from %@", valueIdentity, sender] details:[NSNumber numberWithDouble:value]]; [self log:[NSString stringWithFormat:@"Value %@ from %@", valueIdentity, sender] details:@(value)];
}]; }];
return [LoggingUtil throttleValueLogger:r discardingAfterEventForDuration:0.5]; return [LoggingUtil throttleValueLogger:r discardingAfterEventForDuration:0.5];
} }

@ -16,7 +16,7 @@
} }
-(void) addEventAtTime:(NSTimeInterval)eventTime { -(void) addEventAtTime:(NSTimeInterval)eventTime {
[events enqueue:[NSNumber numberWithDouble:eventTime]]; [events enqueue:@(eventTime)];
} }
-(NSUInteger) countAfterRemovingEventsBeforeWindowEndingAt:(NSTimeInterval)endOfWindowTime { -(NSUInteger) countAfterRemovingEventsBeforeWindowEndingAt:(NSTimeInterval)endOfWindowTime {

@ -7,7 +7,7 @@
NSUInteger n = [self count]; NSUInteger n = [self count];
uint8_t x[n]; uint8_t x[n];
for (NSUInteger i = 0; i < n; i++) { for (NSUInteger i = 0; i < n; i++) {
x[i] = [(NSNumber*)[self objectAtIndex:i] unsignedCharValue]; x[i] = [(NSNumber*)self[i] unsignedCharValue];
} }
return [NSData dataWithBytes:x length:n]; return [NSData dataWithBytes:x length:n];
} }

@ -30,7 +30,7 @@
} }
-(uint32_t) hash:(NSData*)value index:(NSUInteger)index { -(uint32_t) hash:(NSData*)value index:(NSUInteger)index {
NSData* key = [[[NSNumber numberWithUnsignedInteger:index] stringValue] encodedAsAscii]; NSData* key = [[@(index) stringValue] encodedAsAscii];
NSData* hash = [value hmacWithSha1WithKey:key]; NSData* hash = [value hmacWithSha1WithKey:key];
return [hash bigEndianUInt32At:0] % ([data length] * 8); return [hash bigEndianUInt32At:0] % ([data length] * 8);
} }

@ -32,7 +32,7 @@
const uint8_t* subDataBytes = [subData bytes]; const uint8_t* subDataBytes = [subData bytes];
for (NSUInteger i = 0; i <= excessLength; i++) { for (NSUInteger i = 0; i <= excessLength; i++) {
if (memcmp(selfBytes+i, subDataBytes, subDataLength) == 0) { if (memcmp(selfBytes+i, subDataBytes, subDataLength) == 0) {
return [NSNumber numberWithUnsignedInteger:i]; return @(i);
} }
} }
return nil; return nil;

@ -83,13 +83,13 @@
@implementation NSNumber (NumberUtil) @implementation NSNumber (NumberUtil)
-(bool) hasUnsignedIntegerValue { -(bool) hasUnsignedIntegerValue {
return [self isEqual:[NSNumber numberWithUnsignedInteger:[self unsignedIntegerValue]]]; return [self isEqual:@([self unsignedIntegerValue])];
} }
-(bool) hasUnsignedLongLongValue { -(bool) hasUnsignedLongLongValue {
return [self isEqual:[NSNumber numberWithUnsignedLongLong:[self unsignedLongLongValue]]]; return [self isEqual:@([self unsignedLongLongValue])];
} }
-(bool) hasLongLongValue { -(bool) hasLongLongValue {
return [self isEqual:[NSNumber numberWithLongLong:[self longLongValue]]]; return [self isEqual:@([self longLongValue])];
} }
@end @end

@ -7,8 +7,7 @@
+ (NSString *)countryNameFromCountryCode:(NSString *)code { + (NSString *)countryNameFromCountryCode:(NSString *)code {
NSDictionary *countryCodeComponent = [NSDictionary dictionaryWithObject:code NSDictionary *countryCodeComponent = @{NSLocaleCountryCode: code};
forKey:NSLocaleCountryCode];
NSString *identifier = [NSLocale localeIdentifierFromComponents:countryCodeComponent]; NSString *identifier = [NSLocale localeIdentifierFromComponents:countryCodeComponent];
NSString *country = [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier NSString *country = [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier
value:identifier]; value:identifier];

@ -16,7 +16,7 @@
[items addObject:item]; [items addObject:item];
while (curIndex > 0) { while (curIndex > 0) {
NSUInteger parentIndex = (curIndex - 1) >> 1; NSUInteger parentIndex = (curIndex - 1) >> 1;
id parentItem = [items objectAtIndex:parentIndex]; id parentItem = items[parentIndex];
if (_comparator(item, parentItem) >= 0) break; if (_comparator(item, parentItem) >= 0) break;
[items setObject:parentItem atIndexedSubscript:curIndex]; [items setObject:parentItem atIndexedSubscript:curIndex];
@ -27,24 +27,24 @@
-(id)peek { -(id)peek {
requireState([items count] > 0); requireState([items count] > 0);
return [items objectAtIndex:0]; return items[0];
} }
-(id) dequeue { -(id) dequeue {
requireState([items count] > 0); requireState([items count] > 0);
id result = [items objectAtIndex:0]; id result = items[0];
// iteratively pull up smaller child until we hit the bottom of the heap // iteratively pull up smaller child until we hit the bottom of the heap
NSUInteger endangeredIndex = [items count] - 1; NSUInteger endangeredIndex = [items count] - 1;
id endangeredItem = [items objectAtIndex:endangeredIndex]; id endangeredItem = items[endangeredIndex];
NSUInteger i = 0; NSUInteger i = 0;
while (true) { while (true) {
NSUInteger childIndex1 = i*2+1; NSUInteger childIndex1 = i*2+1;
NSUInteger childIndex2 = i*2+2; NSUInteger childIndex2 = i*2+2;
if (childIndex1 >= endangeredIndex) break; if (childIndex1 >= endangeredIndex) break;
NSUInteger smallerChildIndex = _comparator([items objectAtIndex:childIndex1], [items objectAtIndex:childIndex2]) <= 0 ? childIndex1 : childIndex2; NSUInteger smallerChildIndex = _comparator(items[childIndex1], items[childIndex2]) <= 0 ? childIndex1 : childIndex2;
id smallerChild = [items objectAtIndex:smallerChildIndex]; id smallerChild = items[smallerChildIndex];
bool useEndangered = _comparator(endangeredItem, smallerChild) <= 0; bool useEndangered = _comparator(endangeredItem, smallerChild) <= 0;
if (useEndangered) break; if (useEndangered) break;

@ -19,17 +19,17 @@
} }
-(id) dequeue { -(id) dequeue {
requireState([self count] > 0); requireState([self count] > 0);
id result = [items objectAtIndex:0]; id result = items[0];
[items removeObjectAtIndex:0]; [items removeObjectAtIndex:0];
return result; return result;
} }
-(id) peek { -(id) peek {
requireState([self count] > 0); requireState([self count] > 0);
return [items objectAtIndex:0]; return items[0];
} }
-(id) peekAt:(NSUInteger)offset { -(id) peekAt:(NSUInteger)offset {
require(offset < [self count]); require(offset < [self count]);
return [items objectAtIndex:offset]; return items[offset];
} }
-(NSUInteger) count { -(NSUInteger) count {
return [items count]; return [items count];

@ -73,7 +73,7 @@ typedef NSComparisonResult (^CallComparator)(RecentCall*, RecentCall*);
- (void)deleteRecentCallAtIndexPath:(NSIndexPath *)indexPath { - (void)deleteRecentCallAtIndexPath:(NSIndexPath *)indexPath {
[_recentCallsTableView beginUpdates]; [_recentCallsTableView beginUpdates];
[_recentCallsTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] [_recentCallsTableView deleteRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationLeft]; withRowAnimation:UITableViewRowAnimationLeft];
RecentCall *recent; RecentCall *recent;
@ -114,7 +114,7 @@ typedef NSComparisonResult (^CallComparator)(RecentCall*, RecentCall*);
NSIndexPath *indexPath = [_recentCallsTableView indexPathForCell:cell]; NSIndexPath *indexPath = [_recentCallsTableView indexPathForCell:cell];
[_recentCallsTableView beginUpdates]; [_recentCallsTableView beginUpdates];
[_recentCallsTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] [_recentCallsTableView deleteRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationLeft]; withRowAnimation:UITableViewRowAnimationLeft];
RecentCall *recent = _recents[(NSUInteger)indexPath.row]; RecentCall *recent = _recents[(NSUInteger)indexPath.row];
@ -155,9 +155,9 @@ typedef NSComparisonResult (^CallComparator)(RecentCall*, RecentCall*);
#pragma mark - Keyboard #pragma mark - Keyboard
- (void)keyboardWillShow:(NSNotification *)notification { - (void)keyboardWillShow:(NSNotification *)notification {
double duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; double duration = [[notification userInfo][UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:duration animations:^{ [UIView animateWithDuration:duration animations:^{
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; CGSize keyboardSize = [[notification userInfo][UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
CGFloat height = CGRectGetHeight(_recentCallsTableView.frame) - (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT); CGFloat height = CGRectGetHeight(_recentCallsTableView.frame) - (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT);
_recentCallsTableView.frame = CGRectMake(CGRectGetMinX(_recentCallsTableView.frame), _recentCallsTableView.frame = CGRectMake(CGRectGetMinX(_recentCallsTableView.frame),
CGRectGetMinY(_recentCallsTableView.frame), CGRectGetMinY(_recentCallsTableView.frame),
@ -167,7 +167,7 @@ typedef NSComparisonResult (^CallComparator)(RecentCall*, RecentCall*);
} }
- (void)keyboardWillHide:(NSNotification *)notification { - (void)keyboardWillHide:(NSNotification *)notification {
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size; CGSize keyboardSize = [[notification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
CGFloat height = CGRectGetHeight(_recentCallsTableView.frame) + (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT); CGFloat height = CGRectGetHeight(_recentCallsTableView.frame) + (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT);
_recentCallsTableView.frame = CGRectMake(CGRectGetMinX(_recentCallsTableView.frame), _recentCallsTableView.frame = CGRectMake(CGRectGetMinX(_recentCallsTableView.frame),
CGRectGetMinY(_recentCallsTableView.frame), CGRectGetMinY(_recentCallsTableView.frame),

@ -161,7 +161,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
} }
- (NSArray *)contactsForSectionIndex:(NSUInteger)index { - (NSArray *)contactsForSectionIndex:(NSUInteger)index {
return [_latestAlphabeticalContacts valueForKey:[_latestSortedAlphabeticalContactKeys objectAtIndex:index]]; return [_latestAlphabeticalContacts valueForKey:_latestSortedAlphabeticalContactKeys[index]];
} }
- (void)pushContactViewControllerForContactIndexPath:(NSIndexPath *)indexPath { - (void)pushContactViewControllerForContactIndexPath:(NSIndexPath *)indexPath {
@ -178,7 +178,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
} }
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return [_latestSortedAlphabeticalContactKeys objectAtIndex:(NSUInteger)section]; return _latestSortedAlphabeticalContactKeys[(NSUInteger)section];
} }
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
@ -230,9 +230,9 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
#pragma mark - Keyboard #pragma mark - Keyboard
- (void)keyboardWillShow:(NSNotification *)notification { - (void)keyboardWillShow:(NSNotification *)notification {
double duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; double duration = [[notification userInfo][UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:duration animations:^{ [UIView animateWithDuration:duration animations:^{
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; CGSize keyboardSize = [[notification userInfo][UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
_contactTableView.frame = CGRectMake(CGRectGetMinX(_contactTableView.frame), _contactTableView.frame = CGRectMake(CGRectGetMinX(_contactTableView.frame),
CGRectGetMinY(_contactTableView.frame), CGRectGetMinY(_contactTableView.frame),
CGRectGetWidth(_contactTableView.frame), CGRectGetWidth(_contactTableView.frame),
@ -241,7 +241,7 @@ static NSString *const CONTACT_BROWSE_TABLE_CELL_IDENTIFIER = @"ContactTableView
} }
- (void)keyboardWillHide:(NSNotification *)notification { - (void)keyboardWillHide:(NSNotification *)notification {
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size; CGSize keyboardSize = [[notification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
_contactTableView.frame = CGRectMake(CGRectGetMinX(_contactTableView.frame), _contactTableView.frame = CGRectMake(CGRectGetMinX(_contactTableView.frame),
CGRectGetMinY(_contactTableView.frame), CGRectGetMinY(_contactTableView.frame),
CGRectGetWidth(_contactTableView.frame), CGRectGetWidth(_contactTableView.frame),

@ -157,9 +157,9 @@ static NSString *const CONTACT_TABLE_VIEW_CELL_IDENTIFIER = @"ContactTableViewCe
#pragma mark - Keyboard #pragma mark - Keyboard
- (void)keyboardWillShow:(NSNotification *)notification { - (void)keyboardWillShow:(NSNotification *)notification {
double duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; double duration = [[notification userInfo][UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:duration animations:^{ [UIView animateWithDuration:duration animations:^{
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; CGSize keyboardSize = [[notification userInfo][UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
CGFloat height = CGRectGetHeight(_favouriteTableView.frame) - (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT); CGFloat height = CGRectGetHeight(_favouriteTableView.frame) - (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT);
_favouriteTableView.frame = CGRectMake(CGRectGetMinX(_favouriteTableView.frame), _favouriteTableView.frame = CGRectMake(CGRectGetMinX(_favouriteTableView.frame),
CGRectGetMinY(_favouriteTableView.frame), CGRectGetMinY(_favouriteTableView.frame),
@ -169,7 +169,7 @@ static NSString *const CONTACT_TABLE_VIEW_CELL_IDENTIFIER = @"ContactTableViewCe
} }
- (void)keyboardWillHide:(NSNotification *)notification { - (void)keyboardWillHide:(NSNotification *)notification {
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size; CGSize keyboardSize = [[notification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
CGFloat height = CGRectGetHeight(_favouriteTableView.frame) + (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT); CGFloat height = CGRectGetHeight(_favouriteTableView.frame) + (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT);
_favouriteTableView.frame = CGRectMake(CGRectGetMinX(_favouriteTableView.frame), _favouriteTableView.frame = CGRectMake(CGRectGetMinX(_favouriteTableView.frame),
CGRectGetMinY(_favouriteTableView.frame), CGRectGetMinY(_favouriteTableView.frame),

@ -174,7 +174,7 @@ static NSString *const FOOTER_TABLE_CELL_IDENTIFIER = @"InboxFeedFooterCell";
[[[Environment getCurrent] recentCallManager] archiveRecentCall:recent]; [[[Environment getCurrent] recentCallManager] archiveRecentCall:recent];
} }
[_inboxFeedTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] [_inboxFeedTableView deleteRowsAtIndexPaths:@[indexPath]
withRowAnimation:animation]; withRowAnimation:animation];
[_inboxFeedTableView endUpdates]; [_inboxFeedTableView endUpdates];
@ -399,9 +399,9 @@ static NSString *const FOOTER_TABLE_CELL_IDENTIFIER = @"InboxFeedFooterCell";
#pragma mark - Keyboard #pragma mark - Keyboard
- (void)keyboardWillShow:(NSNotification *)notification { - (void)keyboardWillShow:(NSNotification *)notification {
double duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; double duration = [[notification userInfo][UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:duration animations:^{ [UIView animateWithDuration:duration animations:^{
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; CGSize keyboardSize = [[notification userInfo][UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
CGFloat height = CGRectGetHeight(_inboxFeedTableView.frame) - (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT); CGFloat height = CGRectGetHeight(_inboxFeedTableView.frame) - (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT);
_inboxFeedTableView.frame = CGRectMake(CGRectGetMinX(_inboxFeedTableView.frame), _inboxFeedTableView.frame = CGRectMake(CGRectGetMinX(_inboxFeedTableView.frame),
CGRectGetMinY(_inboxFeedTableView.frame), CGRectGetMinY(_inboxFeedTableView.frame),
@ -411,7 +411,7 @@ static NSString *const FOOTER_TABLE_CELL_IDENTIFIER = @"InboxFeedFooterCell";
} }
- (void)keyboardWillHide:(NSNotification *)notification { - (void)keyboardWillHide:(NSNotification *)notification {
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size; CGSize keyboardSize = [[notification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
CGFloat height = CGRectGetHeight(_inboxFeedTableView.frame) + (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT); CGFloat height = CGRectGetHeight(_inboxFeedTableView.frame) + (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT);
_inboxFeedTableView.frame = CGRectMake(CGRectGetMinX(_inboxFeedTableView.frame), _inboxFeedTableView.frame = CGRectMake(CGRectGetMinX(_inboxFeedTableView.frame),
CGRectGetMinY(_inboxFeedTableView.frame), CGRectGetMinY(_inboxFeedTableView.frame),

@ -242,9 +242,9 @@ static NSString *const INVITE_CONTACTS_TABLE_CELL_IDENTIFIER = @"ContactTableVie
#pragma mark - Keyboard #pragma mark - Keyboard
- (void)keyboardWillShow:(NSNotification *)notification { - (void)keyboardWillShow:(NSNotification *)notification {
double duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; double duration = [[notification userInfo][UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:duration animations:^{ [UIView animateWithDuration:duration animations:^{
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; CGSize keyboardSize = [[notification userInfo][UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
CGFloat height = CGRectGetHeight(_contactTableView.frame) - (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT); CGFloat height = CGRectGetHeight(_contactTableView.frame) - (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT);
_contactTableView.frame = CGRectMake(CGRectGetMinX(_contactTableView.frame), _contactTableView.frame = CGRectMake(CGRectGetMinX(_contactTableView.frame),
CGRectGetMinY(_contactTableView.frame), CGRectGetMinY(_contactTableView.frame),
@ -254,7 +254,7 @@ static NSString *const INVITE_CONTACTS_TABLE_CELL_IDENTIFIER = @"ContactTableVie
} }
- (void)keyboardWillHide:(NSNotification *)notification { - (void)keyboardWillHide:(NSNotification *)notification {
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size; CGSize keyboardSize = [[notification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
CGFloat height = CGRectGetHeight(_contactTableView.frame) + (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT); CGFloat height = CGRectGetHeight(_contactTableView.frame) + (keyboardSize.height-BOTTOM_TAB_BAR_HEIGHT);
_contactTableView.frame = CGRectMake(CGRectGetMinX(_contactTableView.frame), _contactTableView.frame = CGRectMake(CGRectGetMinX(_contactTableView.frame),
CGRectGetMinY(_contactTableView.frame), CGRectGetMinY(_contactTableView.frame),

@ -74,7 +74,7 @@
effectiveRange:NULL]; effectiveRange:NULL];
NSMutableDictionary *newAttributes = [[NSMutableDictionary alloc] initWithDictionary:attributes]; NSMutableDictionary *newAttributes = [[NSMutableDictionary alloc] initWithDictionary:attributes];
[newAttributes setObject:color forKey:NSForegroundColorAttributeName]; newAttributes[NSForegroundColorAttributeName] = color;
NSString *placeholderString = [placeholder string]; NSString *placeholderString = [placeholder string];
_phoneNumberTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholderString _phoneNumberTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholderString
@ -334,9 +334,9 @@
} }
- (void)keyboardWillShow:(NSNotification *)notification { - (void)keyboardWillShow:(NSNotification *)notification {
double duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; double duration = [[notification userInfo][UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:duration animations:^{ [UIView animateWithDuration:duration animations:^{
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;; CGSize keyboardSize = [[notification userInfo][UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;;
_scrollView.frame = CGRectMake(CGRectGetMinX(_scrollView.frame), _scrollView.frame = CGRectMake(CGRectGetMinX(_scrollView.frame),
CGRectGetMinY(_scrollView.frame)-keyboardSize.height, CGRectGetMinY(_scrollView.frame)-keyboardSize.height,
CGRectGetWidth(_scrollView.frame), CGRectGetWidth(_scrollView.frame),
@ -345,7 +345,7 @@
} }
- (void)keyboardWillHide:(NSNotification *)notification { - (void)keyboardWillHide:(NSNotification *)notification {
double duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; double duration = [[notification userInfo][UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:duration animations:^{ [UIView animateWithDuration:duration animations:^{
_scrollView.frame = CGRectMake(CGRectGetMinX(_scrollView.frame), _scrollView.frame = CGRectMake(CGRectGetMinX(_scrollView.frame),
CGRectGetMinY(self.view.frame), CGRectGetMinY(self.view.frame),

@ -126,8 +126,8 @@ static NSString *const CHECKBOX_EMPTY_IMAGE_NAME = @"checkbox_empty";
- (void)saveExpandedSectionPreferences { - (void)saveExpandedSectionPreferences {
NSMutableArray *expandedSectionPrefs = [NSMutableArray array]; NSMutableArray *expandedSectionPrefs = [NSMutableArray array];
NSNumber *numberBoolYes = [NSNumber numberWithBool:YES]; NSNumber *numberBoolYes = @YES;
NSNumber *numberBoolNo = [NSNumber numberWithBool:NO]; NSNumber *numberBoolNo = @NO;
[expandedSectionPrefs addObject:(_privacyTableViewCells ? numberBoolYes : numberBoolNo)]; [expandedSectionPrefs addObject:(_privacyTableViewCells ? numberBoolYes : numberBoolNo)];
} }

@ -187,7 +187,7 @@
- (void)newUsersDetected:(NSNotification* )notification { - (void)newUsersDetected:(NSNotification* )notification {
dispatch_async( dispatch_get_main_queue(), ^{ dispatch_async( dispatch_get_main_queue(), ^{
NSArray *newUsers = [[notification userInfo] objectForKey:NOTIFICATION_DATAKEY_NEW_USERS]; NSArray *newUsers = [notification userInfo][NOTIFICATION_DATAKEY_NEW_USERS];
[self updateNewUsers:newUsers]; [self updateNewUsers:newUsers];
}); });
} }

@ -11,9 +11,9 @@
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) self = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self owner:self
options:nil] objectAtIndex:0]; options:nil][0];
if (self) { if (self) {
_scrollView.contentSize = CGSizeMake(CGRectGetWidth(_contentContainerView.bounds), _scrollView.contentSize = CGSizeMake(CGRectGetWidth(_contentContainerView.bounds),
CGRectGetHeight(_scrollView.frame)); CGRectGetHeight(_scrollView.frame));

@ -5,7 +5,7 @@
@implementation ContactTableViewCell @implementation ContactTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil] objectAtIndex:0]; self = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil][0];
_contactPictureView.layer.borderColor = [[UIColor lightGrayColor] CGColor]; _contactPictureView.layer.borderColor = [[UIColor lightGrayColor] CGColor];
_contactPictureView.layer.masksToBounds = YES; _contactPictureView.layer.masksToBounds = YES;
return self; return self;

@ -5,7 +5,7 @@
@implementation FavouriteTableViewCell @implementation FavouriteTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil] objectAtIndex:0]; self = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil][0];
_contactPictureView.layer.borderColor = [[UIColor lightGrayColor] CGColor]; _contactPictureView.layer.borderColor = [[UIColor lightGrayColor] CGColor];
_contactPictureView.layer.masksToBounds = YES; _contactPictureView.layer.masksToBounds = YES;
return self; return self;

@ -13,9 +13,9 @@
@implementation InboxFeedTableViewCell @implementation InboxFeedTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) self = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self owner:self
options:nil] objectAtIndex:0]; options:nil][0];
if (self) { if (self) {

@ -51,14 +51,14 @@
test([[h0 method] isEqualToString:@"GET"]); test([[h0 method] isEqualToString:@"GET"]);
test([[h0 location] isEqualToString:@"/index.html"]); test([[h0 location] isEqualToString:@"/index.html"]);
test([[h0 headers] count] == 1); test([[h0 headers] count] == 1);
test([[[h0 headers] objectForKey:@"Content-Length"] isEqualToString:@"0"]); test([[h0 headers][@"Content-Length"] isEqualToString:@"0"]);
test([[h0 optionalBody] isEqualToString:@""]); test([[h0 optionalBody] isEqualToString:@""]);
HttpRequest* h1 = [HttpRequest httpRequestFromData:[@"GET /index.html HTTP/1.0\r\nContent-Length: 10\r\n\r\nabcdefghij" encodedAsUtf8]]; HttpRequest* h1 = [HttpRequest httpRequestFromData:[@"GET /index.html HTTP/1.0\r\nContent-Length: 10\r\n\r\nabcdefghij" encodedAsUtf8]];
test([[h1 method] isEqualToString:@"GET"]); test([[h1 method] isEqualToString:@"GET"]);
test([[h1 location] isEqualToString:@"/index.html"]); test([[h1 location] isEqualToString:@"/index.html"]);
test([[h1 headers] count] == 1); test([[h1 headers] count] == 1);
test([[[h1 headers] objectForKey:@"Content-Length"] isEqualToString:@"10"]); test([[h1 headers][@"Content-Length"] isEqualToString:@"10"]);
test([[h1 optionalBody] isEqualToString:@"abcdefghij"]); test([[h1 optionalBody] isEqualToString:@"abcdefghij"]);
HttpRequest* h = [HttpRequest httpRequestFromData:[@"GET /index.html HTTP/1.0\r\n\r\n" encodedAsUtf8]]; HttpRequest* h = [HttpRequest httpRequestFromData:[@"GET /index.html HTTP/1.0\r\n\r\n" encodedAsUtf8]];

@ -15,7 +15,7 @@
-(void) testRawDataSimple { -(void) testRawDataSimple {
RtpPacket* r = [RtpPacket rtpPacketWithVersion:2 RtpPacket* r = [RtpPacket rtpPacketWithVersion:2
andPadding:0 andPadding:0
andContributingSourceIdentifiers:[NSArray array] andContributingSourceIdentifiers:@[]
andSynchronizationSourceIdentifier:0 andSynchronizationSourceIdentifier:0
andMarkerBit:false andMarkerBit:false
andPayloadtype:0 andPayloadtype:0
@ -89,7 +89,7 @@
-(void) testExtendedData { -(void) testExtendedData {
RtpPacket* r = [RtpPacket rtpPacketWithVersion:2 RtpPacket* r = [RtpPacket rtpPacketWithVersion:2
andPadding:0 andPadding:0
andContributingSourceIdentifiers:[NSArray array] andContributingSourceIdentifiers:@[]
andSynchronizationSourceIdentifier:0 andSynchronizationSourceIdentifier:0
andExtensionIdentifier:0xFEAB andExtensionIdentifier:0xFEAB
andExtensionData:increasingDataFrom(10, 5) andExtensionData:increasingDataFrom(10, 5)

@ -15,7 +15,7 @@
-(void) testMap { -(void) testMap {
test([[@[] map:^(id x) { return x; }] isEqualToArray:@[]]); test([[@[] map:^(id x) { return x; }] isEqualToArray:@[]]);
test([[(@[@1,@2]) map:^(id x) { return x; }] isEqualToArray:(@[@1,@2])]); test([[(@[@1,@2]) map:^(id x) { return x; }] isEqualToArray:(@[@1,@2])]);
test([[(@[@1,@2]) map:^(NSNumber* x) { return [NSNumber numberWithInt:[x intValue] + 1]; }] isEqualToArray:(@[@2,@3])]); test([[(@[@1,@2]) map:^(NSNumber* x) { return @([x intValue] + 1); }] isEqualToArray:(@[@2,@3])]);
} }
-(void) testFilter { -(void) testFilter {
test([[@[] filter:^(id x) { return true; }] isEqualToArray:@[]]); test([[@[] filter:^(id x) { return true; }] isEqualToArray:@[]]);
@ -42,14 +42,14 @@
test([[@[@1] keyedBy:^id(id value) { return @true; }] isEqual:@{@true : @1}]); test([[@[@1] keyedBy:^id(id value) { return @true; }] isEqual:@{@true : @1}]);
testThrows(([(@[@1, @2]) keyedBy:^id(id value) { return @true; }])); testThrows(([(@[@1, @2]) keyedBy:^id(id value) { return @true; }]));
test([[(@[@1, @2]) keyedBy:^id(id value) { return value; }] isEqual:(@{@1 : @1, @2 : @2})]); test([[(@[@1, @2]) keyedBy:^id(id value) { return value; }] isEqual:(@{@1 : @1, @2 : @2})]);
testThrows([(@[@1, @1, @2, @3, @5]) keyedBy:^id(id value) { return [NSNumber numberWithInt:[value intValue]/2]; }]); testThrows([(@[@1, @1, @2, @3, @5]) keyedBy:^id(id value) { return @([value intValue]/2); }]);
test([[(@[@3, @5, @7, @11, @13]) keyedBy:^id(id value) { return [NSNumber numberWithInt:[value intValue]/2]; }] isEqual:(@{@1 : @3, @2 : @5, @3 : @7, @5 : @11, @6 : @13})]); test([[(@[@3, @5, @7, @11, @13]) keyedBy:^id(id value) { return @([value intValue]/2); }] isEqual:(@{@1 : @3, @2 : @5, @3 : @7, @5 : @11, @6 : @13})]);
} }
-(void) testGroupBy { -(void) testGroupBy {
test([[@[] groupBy:^id(id value) { return @true; }] isEqual:@{}]); test([[@[] groupBy:^id(id value) { return @true; }] isEqual:@{}]);
test([[@[@1] groupBy:^id(id value) { return @true; }] isEqual:@{@true : @[@1]}]); test([[@[@1] groupBy:^id(id value) { return @true; }] isEqual:@{@true : @[@1]}]);
test([[(@[@1, @2]) groupBy:^id(id value) { return @true; }] isEqual:@{@true : (@[@1, @2])}]); test([[(@[@1, @2]) groupBy:^id(id value) { return @true; }] isEqual:@{@true : (@[@1, @2])}]);
test([[(@[@1, @2]) groupBy:^id(id value) { return value; }] isEqual:(@{@1 : @[@1], @2 : @[@2]})]); test([[(@[@1, @2]) groupBy:^id(id value) { return value; }] isEqual:(@{@1 : @[@1], @2 : @[@2]})]);
test([[(@[@1, @1, @2, @3, @5]) groupBy:^id(id value) { return [NSNumber numberWithInt:[value intValue]/2]; }] isEqual:(@{@0 : @[@1, @1], @1 : @[@2, @3], @2 : @[@5]})]); test([[(@[@1, @1, @2, @3, @5]) groupBy:^id(id value) { return @([value intValue]/2); }] isEqual:(@{@0 : @[@1, @1], @1 : @[@2, @3], @2 : @[@5]})]);
} }
@end @end

@ -18,18 +18,18 @@ NSArray* RandomPermutation(NSUInteger count) {
} }
NSMutableArray* r = [NSMutableArray array]; NSMutableArray* r = [NSMutableArray array];
for (NSUInteger i = 0; i < count; i++) for (NSUInteger i = 0; i < count; i++)
[r addObject:[NSNumber numberWithUnsignedInteger:d[i]]]; [r addObject:@(d[i])];
return r; return r;
} }
NSArray* Permutations(NSUInteger count) { NSArray* Permutations(NSUInteger count) {
if (count == 0) return [NSArray array]; if (count == 0) return @[];
NSMutableArray* r = [NSMutableArray array]; NSMutableArray* r = [NSMutableArray array];
for (NSArray* s in Permutations(count - 1)) { for (NSArray* s in Permutations(count - 1)) {
for (NSUInteger e = 0; e < count; e++) { for (NSUInteger e = 0; e < count; e++) {
NSMutableArray* a = [NSMutableArray array]; NSMutableArray* a = [NSMutableArray array];
[a addObject:[NSNumber numberWithUnsignedInteger:e]]; [a addObject:@(e)];
for (NSNumber* x in s) { for (NSNumber* x in s) {
[a addObject:[x unsignedIntegerValue] < e ? x : [NSNumber numberWithUnsignedInteger:[x unsignedIntegerValue] + 1]]; [a addObject:[x unsignedIntegerValue] < e ? x : @([x unsignedIntegerValue] + 1)];
} }
[r addObject:a]; [r addObject:a];
} }

@ -353,7 +353,7 @@
test([@0 hasUnsignedIntegerValue]); test([@0 hasUnsignedIntegerValue]);
test([@1 hasUnsignedIntegerValue]); test([@1 hasUnsignedIntegerValue]);
test([@0xFFFFFFFF hasUnsignedIntegerValue]); test([@0xFFFFFFFF hasUnsignedIntegerValue]);
test([[NSNumber numberWithDouble:pow(2, 31)] hasUnsignedIntegerValue]); test([@(pow(2, 31)) hasUnsignedIntegerValue]);
test(![@-1 hasUnsignedIntegerValue]); test(![@-1 hasUnsignedIntegerValue]);
test(![@0.5 hasUnsignedIntegerValue]); test(![@0.5 hasUnsignedIntegerValue]);
} }
@ -361,8 +361,8 @@
test([@0 hasUnsignedLongLongValue]); test([@0 hasUnsignedLongLongValue]);
test([@1 hasUnsignedLongLongValue]); test([@1 hasUnsignedLongLongValue]);
test([@0xFFFFFFFFFFFFFFFF hasUnsignedLongLongValue]); test([@0xFFFFFFFFFFFFFFFF hasUnsignedLongLongValue]);
test([[NSNumber numberWithDouble:pow(2, 63)] hasUnsignedLongLongValue]); test([@(pow(2, 63)) hasUnsignedLongLongValue]);
test(![[NSNumber numberWithDouble:pow(2, 64)] hasUnsignedLongLongValue]); test(![@(pow(2, 64)) hasUnsignedLongLongValue]);
test(![@-1 hasUnsignedLongLongValue]); test(![@-1 hasUnsignedLongLongValue]);
test(![@0.5 hasUnsignedLongLongValue]); test(![@0.5 hasUnsignedLongLongValue]);
} }
@ -373,9 +373,9 @@
test([@LONG_LONG_MAX hasLongLongValue]); test([@LONG_LONG_MAX hasLongLongValue]);
test([@LONG_LONG_MIN hasLongLongValue]); test([@LONG_LONG_MIN hasLongLongValue]);
test(![@ULONG_LONG_MAX hasLongLongValue]); test(![@ULONG_LONG_MAX hasLongLongValue]);
test([[NSNumber numberWithDouble:pow(2, 62)] hasLongLongValue]); test([@(pow(2, 62)) hasLongLongValue]);
test(![[NSNumber numberWithDouble:pow(2, 63)] hasLongLongValue]); test(![@(pow(2, 63)) hasLongLongValue]);
test(![[NSNumber numberWithDouble:-pow(2, 64)] hasLongLongValue]); test(![@(-pow(2, 64)) hasLongLongValue]);
test(![@0.5 hasLongLongValue]); test(![@0.5 hasLongLongValue]);
} }
-(void) tryParseAsUnsignedInteger { -(void) tryParseAsUnsignedInteger {

Loading…
Cancel
Save