Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Farooq Mulla - #N/A - Converting Project to Support ARC. #30

Open
wants to merge 1 commit 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
8 changes: 3 additions & 5 deletions DBPrefsWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,15 @@

@property (copy) NSString *titlePrefix;

+ (id)sharedPrefsWindowController;
+ (DBPrefsWindowController*)sharedPrefsWindowController;
+ (NSString *)nibName;

- (void)setupToolbar;
- (void)addView:(NSView *)view label:(NSString *)label;
- (void)addView:(NSView *)view label:(NSString *)label image:(NSImage *)image;

- (BOOL)crossFade;
- (void)setCrossFade:(BOOL)fade;
- (BOOL)shiftSlowsAnimation;
- (void)setShiftSlowsAnimation:(BOOL)slows;
@property (NS_NONATOMIC_IOSONLY) BOOL crossFade;
@property (NS_NONATOMIC_IOSONLY) BOOL shiftSlowsAnimation;

- (void)displayViewForIdentifier:(NSString *)identifier animate:(BOOL)animate;
- (void)crossFadeView:(NSView *)oldView withView:(NSView *)newView;
Expand Down
46 changes: 19 additions & 27 deletions DBPrefsWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ @implementation DBPrefsWindowController
#pragma mark Class Methods


+ (id)sharedPrefsWindowController
+ (DBPrefsWindowController*)sharedPrefsWindowController
{
if (!_sharedPrefsWindowController) {
_sharedPrefsWindowController = [[self alloc] initWithWindowNibName:[self nibName]];
Expand All @@ -43,7 +43,7 @@ + (NSString *)nibName
#pragma mark Setup & Teardown


- (id)initWithWindow:(NSWindow *)window
- (instancetype)initWithWindow:(NSWindow *)window
// -initWithWindow: is the designated initializer for NSWindowController.
{
self = [super initWithWindow:nil];
Expand Down Expand Up @@ -134,15 +134,15 @@ - (void)addView:(NSView *)view label:(NSString *)label image:(NSImage *)image
NSString *identifier = [[label copy] autorelease];

[toolbarIdentifiers addObject:identifier];
[toolbarViews setObject:view forKey:identifier];
toolbarViews[identifier] = view;

NSToolbarItem *item = [[[NSToolbarItem alloc] initWithItemIdentifier:identifier] autorelease];
[item setLabel:label];
[item setImage:image];
[item setTarget:self];
[item setAction:@selector(toggleActivePreferenceView:)];

[toolbarItems setObject:item forKey:identifier];
toolbarItems[identifier] = item;
}


Expand Down Expand Up @@ -213,7 +213,7 @@ - (IBAction)showWindow:(id)sender
[toolbar release];
}

NSString *firstIdentifier = [toolbarIdentifiers objectAtIndex:0];
NSString *firstIdentifier = toolbarIdentifiers[0];
[[[self window] toolbar] setSelectedItemIdentifier:firstIdentifier];
[self displayViewForIdentifier:firstIdentifier animate:NO];

Expand Down Expand Up @@ -260,7 +260,7 @@ - (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar

- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)identifier willBeInsertedIntoToolbar:(BOOL)willBeInserted
{
return [toolbarItems objectForKey:identifier];
return toolbarItems[identifier];
(void)toolbar;
(void)willBeInserted;
}
Expand All @@ -279,7 +279,7 @@ - (void)toggleActivePreferenceView:(NSToolbarItem *)toolbarItem
- (void)displayViewForIdentifier:(NSString *)identifier animate:(BOOL)animate
{
// Find the view we want to display.
NSView *newView = [toolbarViews objectForKey:identifier];
NSView *newView = toolbarViews[identifier];

// See if there are any visible views.
NSView *oldView = nil;
Expand Down Expand Up @@ -314,7 +314,7 @@ - (void)displayViewForIdentifier:(NSString *)identifier animate:(BOOL)animate
[[self window] setFrame:[self frameForView:newView] display:YES animate:animate];
}

[[self window] setTitle:[[toolbarItems objectForKey:identifier] label]];
[[self window] setTitle:[toolbarItems[identifier] label]];
}
}

Expand All @@ -334,27 +334,19 @@ - (void)crossFadeView:(NSView *)oldView withView:(NSView *)newView
else
[viewAnimation setDuration:0.25];

NSDictionary *fadeOutDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
oldView, NSViewAnimationTargetKey,
NSViewAnimationFadeOutEffect, NSViewAnimationEffectKey,
nil];

NSDictionary *fadeInDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
newView, NSViewAnimationTargetKey,
NSViewAnimationFadeInEffect, NSViewAnimationEffectKey,
nil];

NSDictionary *resizeDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
[self window], NSViewAnimationTargetKey,
[NSValue valueWithRect:[[self window] frame]], NSViewAnimationStartFrameKey,
[NSValue valueWithRect:[self frameForView:newView]], NSViewAnimationEndFrameKey,
nil];
NSDictionary *fadeOutDictionary = @{NSViewAnimationTargetKey: oldView,
NSViewAnimationEffectKey: NSViewAnimationFadeOutEffect};

NSDictionary *fadeInDictionary = @{NSViewAnimationTargetKey: newView,
NSViewAnimationEffectKey: NSViewAnimationFadeInEffect};

NSDictionary *resizeDictionary = @{NSViewAnimationTargetKey: [self window],
NSViewAnimationStartFrameKey: [NSValue valueWithRect:[[self window] frame]],
NSViewAnimationEndFrameKey: [NSValue valueWithRect:[self frameForView:newView]]};

NSArray *animationArray = [NSArray arrayWithObjects:
fadeOutDictionary,
NSArray *animationArray = @[fadeOutDictionary,
fadeInDictionary,
resizeDictionary,
nil];
resizeDictionary];

[viewAnimation setViewAnimations:animationArray];
[viewAnimation startAnimation];
Expand Down
19 changes: 12 additions & 7 deletions Fragaria.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
ABCA4DA616137FC000E4849B /* DBPrefsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABC1D5D5160B0801008769EB /* DBPrefsWindowController.m */; };
ABCA4DA816137FC000E4849B /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
ABCA4DA916137FC000E4849B /* MGSFragaria.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB69B62B118B745700903D1D /* MGSFragaria.framework */; };
ABCA4DAB16137FC000E4849B /* MGSFragaria.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB69B62B118B745700903D1D /* MGSFragaria.framework */; };
ABD0FDB01193281600E6AFE6 /* MGSFragaria.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB69B62B118B745700903D1D /* MGSFragaria.framework */; };
ABCA4DAB16137FC000E4849B /* MGSFragaria.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB69B62B118B745700903D1D /* MGSFragaria.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
ABD0FDB01193281600E6AFE6 /* MGSFragaria.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB69B62B118B745700903D1D /* MGSFragaria.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
ABE25D0A1635CA7C00F23718 /* MGSFragariaPrefsViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = ABE25D081635CA7C00F23718 /* MGSFragariaPrefsViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
ABE25D0B1635CA7C00F23718 /* MGSFragariaPrefsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABE25D091635CA7C00F23718 /* MGSFragariaPrefsViewController.m */; };
ABF28AF014C075D400ECAD48 /* NSScanner+Fragaria.m in Sources */ = {isa = PBXBuildFile; fileRef = ABF28AEE14C075D400ECAD48 /* NSScanner+Fragaria.m */; };
Expand Down Expand Up @@ -740,7 +740,7 @@
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0450;
LastUpgradeCheck = 0610;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Fragaria" */;
compatibilityVersion = "Xcode 3.2";
Expand Down Expand Up @@ -995,18 +995,20 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_GC = unsupported;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
INFOPLIST_FILE = "MGSFragaria-Info.plist";
INSTALL_PATH = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.5;
MACOSX_DEPLOYMENT_TARGET = 10.9;
ONLY_ACTIVE_ARCH = NO;
OTHER_LDFLAGS = (
"-framework",
Expand All @@ -1015,6 +1017,7 @@
AppKit,
);
PRODUCT_NAME = MGSFragaria;
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
Expand All @@ -1023,17 +1026,19 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
GCC_ENABLE_OBJC_GC = unsupported;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
INFOPLIST_FILE = "MGSFragaria-Info.plist";
INSTALL_PATH = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.5;
MACOSX_DEPLOYMENT_TARGET = 10.9;
ONLY_ACTIVE_ARCH = NO;
OTHER_LDFLAGS = (
"-framework",
Expand Down Expand Up @@ -1085,6 +1090,7 @@
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_GC = unsupported;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Fragaria_Prefix.pch;
Expand All @@ -1100,6 +1106,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
COMBINE_HIDPI_IMAGES = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_OBJC_GC = unsupported;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Fragaria_Prefix.pch;
INFOPLIST_FILE = "Fragaria-Info.plist";
Expand All @@ -1112,7 +1119,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_GC = supported;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -1152,7 +1158,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_GC = supported;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down
13 changes: 6 additions & 7 deletions ICUMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
@abstract Finds the next occurrence of the pattern in the input string.
@discussion Use <code>group</code> and <code>rangeOfMatch</code> to extract the match.
*/
-(BOOL)findNext;
@property (NS_NONATOMIC_IOSONLY, readonly) BOOL findNext;

/*!
@method findFromIndex:
Expand All @@ -51,7 +51,7 @@
@abstract Returns the current match.
@discussion Each match has one or more subexpressions associated with the match. This returns the entire match.
*/
-(NSString *)group;
@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *group;

/*!
@method groupAtIndex:
Expand All @@ -65,7 +65,7 @@
@abstract Returns the number of groups for the current match.
@discussion Group 0 is the entire match and groups 1..n represent the groups for the subexpressions.
*/
-(unsigned)numberOfGroups;
@property (NS_NONATOMIC_IOSONLY, readonly) unsigned int numberOfGroups;

/*!
@method lookingAt:
Expand All @@ -79,15 +79,14 @@
@abstract Returns the pattern for this matcher.
@discussion
*/
-(ICUPattern *)pattern;
-(void)setPattern:(ICUPattern *)p;
@property (NS_NONATOMIC_IOSONLY, copy) ICUPattern *pattern;

/*!
@method matches
@abstract Returns YES if the patterns matches the <b>entire</b> input string.
@discussion
*/
-(BOOL)matches;
@property (NS_NONATOMIC_IOSONLY, readonly) BOOL matches;

/*!
@method replaceAllWithString:
Expand Down Expand Up @@ -115,7 +114,7 @@
@abstract Returns the range of the input string that corresponds to the current match.
@discussion
*/
-(NSRange)rangeOfMatch;
@property (NS_NONATOMIC_IOSONLY, readonly) NSRange rangeOfMatch;

/*!
@method rangeOfMatchGroup:
Expand Down
24 changes: 12 additions & 12 deletions ICUMatcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ -(NSString *)performReplacementWithString:(NSString *)aReplacementString replace
@implementation ICUMatcher

+(ICUMatcher *)matcherWithPattern:(ICUPattern *)p overString:(NSString *)stringToSearchOver {
return [[[[ICUMatcher class] alloc] initWithPattern:p overString:stringToSearchOver] autorelease];
return [[[ICUMatcher class] alloc] initWithPattern:p overString:stringToSearchOver];
}

-(ICUMatcher *)initWithPattern:(ICUPattern *)p overString:(NSString *)aStringToSearch {
Expand Down Expand Up @@ -105,19 +105,19 @@ -(NSString *)groupAtIndex:(unsigned)groupIndex {

while(YES) {
UErrorCode status = 0;
UChar *dest = (UChar *)NSZoneCalloc([self zone], groupSize, sizeof(UChar));
UChar *dest = (UChar *)NSZoneCalloc(nil, groupSize, sizeof(UChar));
int32_t buffSize = uregex_group(re, groupIndex, dest, (int32_t)groupSize, &status);

if(U_BUFFER_OVERFLOW_ERROR == status) {
groupSize *= 2;
NSZoneFree([self zone], dest);
NSZoneFree(nil, dest);
continue;
}

CheckStatus(status);

NSString *result = [[[NSString alloc] initWithBytes:dest length:buffSize*sizeof(UChar) encoding:[NSString nativeUTF16Encoding]] autorelease];
NSZoneFree([self zone], dest);
NSString *result = [[NSString alloc] initWithBytes:dest length:buffSize*sizeof(UChar) encoding:[NSString nativeUTF16Encoding]];
NSZoneFree(nil, dest);
return result;
}
}
Expand Down Expand Up @@ -159,7 +159,7 @@ -(NSString *)performReplacementWithString:(NSString *)aReplacementString replace
while(!replacementCompleted) {

if(!destString) // attempts to increase buffer happen on failure below
destString = NSZoneCalloc([self zone], destStringBufferSize, sizeof(UChar));
destString = NSZoneCalloc(nil, destStringBufferSize, sizeof(UChar));

if(!destString)
[NSException raise:@"Find Exception"
Expand All @@ -177,26 +177,26 @@ -(NSString *)performReplacementWithString:(NSString *)aReplacementString replace
destStringBufferSize = resultLength + 1;

UChar *prevString = destString;
destString = NSZoneRealloc([self zone], destString, destStringBufferSize*sizeof(UChar));
destString = NSZoneRealloc(nil, destString, destStringBufferSize*sizeof(UChar));

if(destString == NULL) {
NSZoneFree([self zone], prevString);
NSZoneFree(nil, prevString);
[NSException raise:@"Find Exception"
format:@"Could not allocate memory for replacement string"];
}
} else if(U_FAILURE(status)) {
NSZoneFree([self zone], destString);
NSZoneFree(nil, destString);
[NSException raise:@"Find Exception"
format:@"Could not perform find and replace: %s", u_errorName(status)];
} else {
replacementCompleted = YES;
}
}

NSString *result = [[[NSString alloc] initWithBytes:destString
NSString *result = [[NSString alloc] initWithBytes:destString
length:resultLength * sizeof(UChar)
encoding:[NSString nativeUTF16Encoding]] autorelease];
NSZoneFree([self zone], destString);
encoding:[NSString nativeUTF16Encoding]];
NSZoneFree(nil, destString);
return result;
}

Expand Down
Loading