diff --git a/DBPrefsWindowController.h b/DBPrefsWindowController.h
index c4c0623a..1487ceb6 100644
--- a/DBPrefsWindowController.h
+++ b/DBPrefsWindowController.h
@@ -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;
diff --git a/DBPrefsWindowController.m b/DBPrefsWindowController.m
index 67a5b327..be47659a 100644
--- a/DBPrefsWindowController.m
+++ b/DBPrefsWindowController.m
@@ -19,7 +19,7 @@ @implementation DBPrefsWindowController
#pragma mark Class Methods
-+ (id)sharedPrefsWindowController
++ (DBPrefsWindowController*)sharedPrefsWindowController
{
if (!_sharedPrefsWindowController) {
_sharedPrefsWindowController = [[self alloc] initWithWindowNibName:[self nibName]];
@@ -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];
@@ -134,7 +134,7 @@ - (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];
@@ -142,7 +142,7 @@ - (void)addView:(NSView *)view label:(NSString *)label image:(NSImage *)image
[item setTarget:self];
[item setAction:@selector(toggleActivePreferenceView:)];
- [toolbarItems setObject:item forKey:identifier];
+ toolbarItems[identifier] = item;
}
@@ -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];
@@ -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;
}
@@ -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;
@@ -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]];
}
}
@@ -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];
diff --git a/Fragaria.xcodeproj/project.pbxproj b/Fragaria.xcodeproj/project.pbxproj
index ec6e8973..03b2bc71 100644
--- a/Fragaria.xcodeproj/project.pbxproj
+++ b/Fragaria.xcodeproj/project.pbxproj
@@ -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 */; };
@@ -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";
@@ -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",
@@ -1015,6 +1017,7 @@
AppKit,
);
PRODUCT_NAME = MGSFragaria;
+ VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
@@ -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",
@@ -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;
@@ -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";
@@ -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;
@@ -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;
diff --git a/ICUMatcher.h b/ICUMatcher.h
index d79a24e4..3172b754 100644
--- a/ICUMatcher.h
+++ b/ICUMatcher.h
@@ -37,7 +37,7 @@
@abstract Finds the next occurrence of the pattern in the input string.
@discussion Use group and rangeOfMatch to extract the match.
*/
--(BOOL)findNext;
+@property (NS_NONATOMIC_IOSONLY, readonly) BOOL findNext;
/*!
@method findFromIndex:
@@ -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:
@@ -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:
@@ -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 entire input string.
@discussion
*/
--(BOOL)matches;
+@property (NS_NONATOMIC_IOSONLY, readonly) BOOL matches;
/*!
@method replaceAllWithString:
@@ -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:
diff --git a/ICUMatcher.m b/ICUMatcher.m
index de7812f5..ed4907fa 100644
--- a/ICUMatcher.m
+++ b/ICUMatcher.m
@@ -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 {
@@ -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;
}
}
@@ -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"
@@ -177,15 +177,15 @@ -(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 {
@@ -193,10 +193,10 @@ -(NSString *)performReplacementWithString:(NSString *)aReplacementString replace
}
}
- 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;
}
diff --git a/ICUPattern.h b/ICUPattern.h
index f615b4fc..5ee1012a 100644
--- a/ICUPattern.h
+++ b/ICUPattern.h
@@ -52,14 +52,14 @@ extern const unsigned ICUUnicodeWordBoundaries;
@abstract Returns a pattern with the specified flags set.
@discussion Flags are defined as the OR of the constants defined in the class.
*/
--(id)initWithString:(NSString *)aPattern flags:(unsigned)flags;
+-(instancetype)initWithString:(NSString *)aPattern flags:(unsigned)flags;
/*!
@method initWithString:
@abstract Returns a pattern with the specified flags set.
@discussion Flags are defined as 0.
*/
--(id)initWithString:(NSString *)aPattern;
+-(instancetype)initWithString:(NSString *)aPattern;
/*!
@method componentsSplitFromString:
@@ -80,14 +80,13 @@ extern const unsigned ICUUnicodeWordBoundaries;
@abstract Returns the string representing the regular expression of this pattern.
@discussion Returns the string representing the regular expression of this pattern.
*/
--(NSString *)pattern;
+@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *pattern;
/*!
@method setStringToSearch:
@abstract Sets the string that is being searched by this pattern.
@discussion This method also resets any internal state of the pattern.
*/
--(void)setStringToSearch:(NSString *)aStringToSearchOver;
/*!
@method stringToSearch
@@ -96,7 +95,7 @@ extern const unsigned ICUUnicodeWordBoundaries;
strings, this may be memory-intensive/time-consuming. Performance-critical applications may want to modify this
class to suite their needs to reduce the number of NSString objects that are created.
*/
--(NSString *)stringToSearch;
+@property (NS_NONATOMIC_IOSONLY, copy) NSString *stringToSearch;
/*!
@method reset
@@ -110,6 +109,6 @@ extern const unsigned ICUUnicodeWordBoundaries;
@abstract Returns the compiled ICU URegularExpression for this pattern.
@discussion This method primarily exists to allow the ICUMatcher to access the pattern.
*/
--(void *)re;
+@property (NS_NONATOMIC_IOSONLY, readonly) void *re;
@end
diff --git a/ICUPattern.m b/ICUPattern.m
index bbd15049..5196025d 100644
--- a/ICUPattern.m
+++ b/ICUPattern.m
@@ -44,11 +44,11 @@ -(UChar *)textToSearch;
@implementation ICUPattern
+(ICUPattern *)patternWithString:(NSString *)aPattern flags:(unsigned)flags {
- return [[[self alloc] initWithString:aPattern flags:flags] autorelease];
+ return [[self alloc] initWithString:aPattern flags:flags];
}
+(ICUPattern *)patternWithString:(NSString *)aPattern {
- return [[[self alloc] initWithString:aPattern flags:0] autorelease];
+ return [[self alloc] initWithString:aPattern flags:0];
}
-(id)initWithString:(NSString *)aPattern flags:(unsigned)f {
@@ -80,7 +80,7 @@ -(id)initWithString:(NSString *)aPattern {
return [self initWithString:aPattern flags:0];
}
--(void)finalize {
+-(void)dealloc {
// if(re != NULL)
// NSZoneFree([self zone], re);
@@ -88,7 +88,6 @@ -(void)finalize {
if(textToSearch != NULL)
free(textToSearch);
- [super finalize];
}
-(NSString *)stringToSearch {
@@ -154,7 +153,7 @@ -(NSString *)pattern {
-(void)setRe:(URegularExpression *)p {
if(re != NULL)
- NSZoneFree([self zone], re);
+ NSZoneFree(nil, re);
re = p;
}
@@ -176,7 +175,7 @@ -(NSString *)description {
format:@"Could not get pattern text from pattern."];
}
- return [[[NSString alloc] initWithBytes:p length:len encoding:[NSString nativeUTF16Encoding]] autorelease];
+ return [[NSString alloc] initWithBytes:p length:len encoding:[NSString nativeUTF16Encoding]];
}
return nil;
@@ -193,7 +192,7 @@ -(NSArray *)componentsSplitFromString:(NSString *)stringToSplit
size_t destCapacity = u_strlen([self textToSearch]);
while(!isDone) {
- UChar *destBuf = (UChar *)NSZoneCalloc([self zone], destCapacity, sizeof(UChar));
+ UChar *destBuf = (UChar *)NSZoneCalloc(nil, destCapacity, sizeof(UChar));
int requiredCapacity = 0;
UChar *destFields[destFieldsCapacity];
int numberOfComponents = uregex_split([self re],
@@ -205,17 +204,17 @@ -(NSArray *)componentsSplitFromString:(NSString *)stringToSplit
&status);
if(status == U_BUFFER_OVERFLOW_ERROR) { // buffer was too small, grow it
- NSZoneFree([self zone], destBuf);
+ NSZoneFree(nil, destBuf);
NSAssert(destCapacity * 2 < INT_MAX, @"Overflow occurred splitting string.");
destCapacity = (destCapacity < (unsigned)requiredCapacity) ? (unsigned)requiredCapacity : destCapacity * 2;
status = 0;
} else if(destFieldsCapacity == numberOfComponents) {
destFieldsCapacity *= 2;
NSAssert(destFieldsCapacity *2 < INT_MAX, @"Overflow occurred splitting string.");
- NSZoneFree([self zone], destBuf);
+ NSZoneFree(nil, destBuf);
status = 0;
} else if(U_FAILURE(status)) {
- NSZoneFree([self zone], destBuf);
+ NSZoneFree(nil, destBuf);
isDone = YES;
} else {
int i;
@@ -231,7 +230,7 @@ -(NSArray *)componentsSplitFromString:(NSString *)stringToSplit
if(U_FAILURE(status))
[NSException raise:@"Split Exception"
- format:@"Unable to split string: %@", [NSString stringWithUTF8String:u_errorName(status)]];
+ format:@"Unable to split string: %@", @(u_errorName(status))];
return [NSArray arrayWithArray:results];
}
diff --git a/MGSExtraInterfaceController.h b/MGSExtraInterfaceController.h
index 30d87a0e..f10ed37e 100644
--- a/MGSExtraInterfaceController.h
+++ b/MGSExtraInterfaceController.h
@@ -29,23 +29,24 @@ Unless required by applicable law or agreed to in writing, software distributed
IBOutlet NSWindow *detabWindow;
IBOutlet NSWindow *goToLineWindow;
- IBOutlet NSView *openPanelAccessoryView;
- IBOutlet NSPopUpButton *openPanelEncodingsPopUp;
+// IBOutlet NSView *openPanelAccessoryView;
+// IBOutlet __weak NSPopUpButton *openPanelEncodingsPopUp;
//IBOutlet NSView *printAccessoryView;
- IBOutlet NSWindow *commandResultWindow;
- IBOutlet NSTextView *commandResultTextView;
+// IBOutlet __weak NSWindow *commandResultWindow;
+// IBOutlet __unsafe_unretained NSTextView *commandResultTextView;
- IBOutlet NSWindow *projectWindow;
- IBOutlet NSPanel *regularExpressionsHelpPanel;
+// IBOutlet __weak NSWindow *projectWindow;
+// IBOutlet __weak NSPanel *regularExpressionsHelpPanel;
}
-@property (readonly) IBOutlet NSView *openPanelAccessoryView;
-@property (readonly) IBOutlet NSPopUpButton *openPanelEncodingsPopUp;
-@property (readonly) IBOutlet NSWindow *commandResultWindow;
-@property (readonly) IBOutlet NSTextView *commandResultTextView;
-@property (readonly) IBOutlet NSWindow *projectWindow;
+@property (weak, readonly) IBOutlet NSView *openPanelAccessoryView;
+@property (weak, readonly) IBOutlet NSPopUpButton *openPanelEncodingsPopUp;
+@property (weak, readonly) IBOutlet NSWindow *commandResultWindow;
+@property (unsafe_unretained, readonly) IBOutlet NSTextView *commandResultTextView;
+@property (weak, readonly) IBOutlet NSWindow *projectWindow;
+@property (weak, readwrite) IBOutlet NSWindow *regularExpressionsHelpPanel;
- (void)displayEntab;
- (void)displayDetab;
diff --git a/MGSExtraInterfaceController.m b/MGSExtraInterfaceController.m
index d07f22fd..a715f358 100644
--- a/MGSExtraInterfaceController.m
+++ b/MGSExtraInterfaceController.m
@@ -36,7 +36,7 @@ @implementation MGSExtraInterfaceController
- init
*/
-- (id)init
+- (instancetype)init
{
self = [super init];
if (self) {
@@ -56,7 +56,7 @@ - (id)init
- (void)displayEntab
{
if (entabWindow == nil) {
- [NSBundle loadNibNamed:@"SMLEntab.nib" owner:self];
+ [[NSBundle mainBundle] loadNibNamed:@"SMLEntab.nib" owner:self topLevelObjects:nil];
}
[NSApp beginSheet:entabWindow modalForWindow:SMLCurrentWindow modalDelegate:self didEndSelector:nil contextInfo:nil];
@@ -70,7 +70,7 @@ - (void)displayEntab
- (void)displayDetab
{
if (detabWindow == nil) {
- [NSBundle loadNibNamed:@"SMLDetab.nib" owner:self];
+ [[NSBundle mainBundle] loadNibNamed:@"SMLDetab.nib" owner:self topLevelObjects:nil];
}
[NSApp beginSheet:detabWindow modalForWindow:SMLCurrentWindow modalDelegate:self didEndSelector:nil contextInfo:nil];
@@ -133,7 +133,7 @@ - (IBAction)cancelButtonEntabDetabGoToLineWindowsAction:(id)sender
- (void)displayGoToLine
{
if (goToLineWindow == nil) {
- [NSBundle loadNibNamed:@"SMLGoToLine.nib" owner:self];
+ [[NSBundle mainBundle] loadNibNamed:@"SMLGoToLine.nib" owner:self topLevelObjects:nil];
}
[NSApp beginSheet:goToLineWindow modalForWindow:SMLCurrentWindow modalDelegate:self didEndSelector:nil contextInfo:nil];
@@ -164,7 +164,7 @@ - (IBAction)goButtonGoToLineWindowAction:(id)sender
- (NSPopUpButton *)openPanelEncodingsPopUp
{
if (openPanelEncodingsPopUp == nil) {
- [NSBundle loadNibNamed:@"SMLOpenPanelAccessoryView.nib" owner:self];
+ [[NSBundle mainBundle] loadNibNamed:@"SMLOpenPanelAccessoryView.nib" owner:self topLevelObjects:nil];
}
return openPanelEncodingsPopUp;
@@ -178,7 +178,7 @@ - (NSPopUpButton *)openPanelEncodingsPopUp
- (NSView *)openPanelAccessoryView
{
if (openPanelAccessoryView == nil) {
- [NSBundle loadNibNamed:@"SMLOpenPanelAccessoryView.nib" owner:self];
+ [[NSBundle mainBundle] loadNibNamed:@"SMLOpenPanelAccessoryView.nib" owner:self topLevelObjects:nil];
}
return openPanelAccessoryView;
@@ -191,11 +191,11 @@ - (NSView *)openPanelAccessoryView
*/
- (void)showRegularExpressionsHelpPanel
{
- if (regularExpressionsHelpPanel == nil) {
- [NSBundle loadNibNamed:@"SMLRegularExpressionHelp.nib" owner:self];
+ if (_regularExpressionsHelpPanel == nil) {
+ [[NSBundle mainBundle] loadNibNamed:@"SMLRegularExpressionHelp.nib" owner:self topLevelObjects:nil];
}
- [regularExpressionsHelpPanel makeKeyAndOrderFront:nil];
+ [_regularExpressionsHelpPanel makeKeyAndOrderFront:nil];
}
#pragma mark -
@@ -209,7 +209,7 @@ - (void)showRegularExpressionsHelpPanel
- (NSWindow *)commandResultWindow
{
if (commandResultWindow == nil) {
- [NSBundle loadNibNamed:@"SMLCommandResult.nib" owner:self];
+ [[NSBundle mainBundle] loadNibNamed:@"SMLCommandResult.nib" owner:self topLevelObjects:nil];
[commandResultWindow setTitle:COMMAND_RESULT_WINDOW_TITLE];
}
@@ -224,8 +224,8 @@ - (NSWindow *)commandResultWindow
- (NSTextView *)commandResultTextView
{
if (commandResultTextView == nil) {
- [NSBundle loadNibNamed:@"SMLCommandResult.nib" owner:self];
- [commandResultWindow setTitle:COMMAND_RESULT_WINDOW_TITLE];
+ [[NSBundle mainBundle] loadNibNamed:@"SMLCommandResult.nib" owner:self topLevelObjects:nil];
+ [commandResultWindow setTitle:COMMAND_RESULT_WINDOW_TITLE];
}
return commandResultTextView;
diff --git a/MGSFragaria.h b/MGSFragaria.h
index 01645e31..26d5adbc 100644
--- a/MGSFragaria.h
+++ b/MGSFragaria.h
@@ -59,8 +59,8 @@ extern NSString * const ro_MGSFOSyntaxColouring; // readonly
NSSet* objectSetterKeys;
}
-@property (nonatomic, readonly, assign) MGSExtraInterfaceController *extraInterfaceController;
-@property (nonatomic, retain) id docSpec;
+@property (nonatomic, readonly) MGSExtraInterfaceController *extraInterfaceController;
+@property (nonatomic, strong) id docSpec;
// class methods
+ (id)currentInstance;
@@ -76,27 +76,22 @@ extern NSString * const ro_MGSFOSyntaxColouring; // readonly
+ (NSAttributedString *)attributedStringWithTemporaryAttributesAppliedForDocSpec:(id)docSpec;
// instance methods
-- (id)initWithObject:(id)object;
+- (instancetype)initWithObject:(id)object NS_DESIGNATED_INITIALIZER;
- (void)setObject:(id)object forKey:(id)key;
- (id)objectForKey:(id)key;
- (void)embedInView:(NSView *)view;
-- (void)setString:(NSString *)aString;
- (void)setString:(NSString *)aString options:(NSDictionary *)options;
-- (void)setAttributedString:(NSAttributedString *)aString;
- (void)setAttributedString:(NSAttributedString *)aString options:(NSDictionary *)options;
-- (NSAttributedString *)attributedString;
-- (NSAttributedString *)attributedStringWithTemporaryAttributesApplied;
-- (NSString *)string;
-- (NSTextView *)textView;
-- (MGSTextMenuController *)textMenuController;
-- (void)setSyntaxColoured:(BOOL)value;
-- (BOOL)isSyntaxColoured;
-- (void)setShowsLineNumbers:(BOOL)value;
-- (BOOL)showsLineNumbers;
+@property (NS_NONATOMIC_IOSONLY, copy) NSAttributedString *attributedString;
+@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSAttributedString *attributedStringWithTemporaryAttributesApplied;
+@property (NS_NONATOMIC_IOSONLY, copy) NSString *string;
+@property (NS_NONATOMIC_IOSONLY, readonly, strong) NSTextView *textView;
+@property (NS_NONATOMIC_IOSONLY, readonly, strong) MGSTextMenuController *textMenuController;
+@property (NS_NONATOMIC_IOSONLY, getter=isSyntaxColoured) BOOL syntaxColoured;
+@property (NS_NONATOMIC_IOSONLY) BOOL showsLineNumbers;
- (void)reloadString;
- (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)text options:(NSDictionary *)options;
-- (void)setSyntaxErrors:(NSArray *)errors;
-- (NSArray *)syntaxErrors;
+@property (NS_NONATOMIC_IOSONLY, copy) NSArray *syntaxErrors;
+ (NSImage *)imageNamed:(NSString *)name;
@end
diff --git a/MGSFragaria.m b/MGSFragaria.m
index 9f089ca0..be773f8b 100644
--- a/MGSFragaria.m
+++ b/MGSFragaria.m
@@ -56,12 +56,12 @@
// class extension
@interface MGSFragaria()
-@property (nonatomic, readwrite, assign) MGSExtraInterfaceController *extraInterfaceController;
+@property (nonatomic, readwrite) MGSExtraInterfaceController *extraInterfaceController;
- (void)updateGutterView;
-@property (nonatomic,retain) NSSet* objectGetterKeys;
-@property (nonatomic,retain) NSSet* objectSetterKeys;
+@property (nonatomic,strong) NSSet* objectGetterKeys;
+@property (nonatomic,strong) NSSet* objectSetterKeys;
@end
@@ -217,7 +217,7 @@ + (NSAttributedString *)attributedStringWithTemporaryAttributesAppliedForDocSpec
// recolour the entire textview content
SMLTextView *textView = [docSpec valueForKey:ro_MGSFOTextView];
SMLSyntaxColouring *syntaxColouring = [docSpec valueForKey:ro_MGSFOSyntaxColouring];
- NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], @"colourAll", nil];
+ NSDictionary *options = @{@"colourAll": @YES};
[syntaxColouring pageRecolourTextView:textView options: options];
// get content with layout manager temporary attributes persisted
@@ -238,7 +238,7 @@ + (NSAttributedString *)attributedStringWithTemporaryAttributesAppliedForDocSpec
eg: Smultron used a CoreData object.
*/
-- (id)initWithObject:(id)object
+- (instancetype)initWithObject:(id)object
{
if ((self = [super init])) {
_currentInstance = self;
@@ -251,7 +251,7 @@ - (id)initWithObject:(id)object
}
// register the font transformer
- FRAFontTransformer *fontTransformer = [[[FRAFontTransformer alloc] init] autorelease];
+ FRAFontTransformer *fontTransformer = [[FRAFontTransformer alloc] init];
[NSValueTransformer setValueTransformer:fontTransformer forName:@"FontTransformer"];
// observe defaults that affect rendering
@@ -286,7 +286,7 @@ - (id)initWithObject:(id)object
- init
*/
-- (id)init
+- (instancetype)init
{
return [self initWithObject:nil];
}
@@ -312,7 +312,7 @@ - (void)embedInView:(NSView *)contentView
Class syntaxColouringClass = [SMLSyntaxColouring class];
// create text scrollview
- NSScrollView *textScrollView = [[[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, [contentView bounds].size.width, [contentView bounds].size.height)] autorelease];
+ NSScrollView *textScrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, [contentView bounds].size.width, [contentView bounds].size.height)];
NSSize contentSize = [textScrollView contentSize];
[textScrollView setBorderType:NSNoBorder];
[textScrollView setHasVerticalScroller:YES];
@@ -322,12 +322,12 @@ - (void)embedInView:(NSView *)contentView
[textScrollView setPostsFrameChangedNotifications:YES];
// create textview
- SMLTextView *textView = [[[editorTextViewClass alloc] initWithFrame:NSMakeRect(0, 0, contentSize.width, contentSize.height)] autorelease];
+ SMLTextView *textView = [[editorTextViewClass alloc] initWithFrame:NSMakeRect(0, 0, contentSize.width, contentSize.height)];
[textView setFragaria:self];
[textScrollView setDocumentView:textView];
// create line numbers
- SMLLineNumbers *lineNumbers = [[[lineNumberClass alloc] initWithDocument:self.docSpec] autorelease];
+ SMLLineNumbers *lineNumbers = [[lineNumberClass alloc] initWithDocument:self.docSpec];
[self.docSpec setValue:lineNumbers forKey:ro_MGSFOLineNumbers];
// SMLLineNumbers will be notified of changes to the text scroll view content view due to scrolling
@@ -335,7 +335,7 @@ - (void)embedInView:(NSView *)contentView
[[NSNotificationCenter defaultCenter] addObserver:lineNumbers selector:@selector(viewBoundsDidChange:) name:NSViewFrameDidChangeNotification object:[textScrollView contentView]];
// create gutter scrollview
- NSScrollView *gutterScrollView = [[[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, gutterWidth, contentSize.height)] autorelease];
+ NSScrollView *gutterScrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, gutterWidth, contentSize.height)];
[gutterScrollView setBorderType:NSNoBorder];
[gutterScrollView setHasVerticalScroller:NO];
[gutterScrollView setHasHorizontalScroller:NO];
@@ -343,7 +343,7 @@ - (void)embedInView:(NSView *)contentView
[[gutterScrollView contentView] setAutoresizesSubviews:YES];
// create gutter textview
- SMLGutterTextView *gutterTextView = [[[gutterTextViewClass alloc] initWithFrame:NSMakeRect(0, 0, gutterWidth, contentSize.height - 50)] autorelease];
+ SMLGutterTextView *gutterTextView = [[gutterTextViewClass alloc] initWithFrame:NSMakeRect(0, 0, gutterWidth, contentSize.height - 50)];
[gutterScrollView setDocumentView:gutterTextView];
// update the docSpec
@@ -352,7 +352,7 @@ - (void)embedInView:(NSView *)contentView
[self.docSpec setValue:gutterScrollView forKey:ro_MGSFOGutterScrollView];
// add syntax colouring
- SMLSyntaxColouring *syntaxColouring = [[[syntaxColouringClass alloc] initWithDocument:self.docSpec] autorelease];
+ SMLSyntaxColouring *syntaxColouring = [[syntaxColouringClass alloc] initWithDocument:self.docSpec];
[self.docSpec setValue:syntaxColouring forKey:ro_MGSFOSyntaxColouring];
[self.docSpec setValue:syntaxColouring forKey:MGSFOAutoCompleteDelegate];
@@ -492,7 +492,7 @@ - (NSTextView *)textView
*/
- (void)setShowsLineNumbers:(BOOL)value
{
- [self setObject:[NSNumber numberWithBool:value] forKey:MGSFOShowLineNumberGutter];
+ [self setObject:@(value) forKey:MGSFOShowLineNumberGutter];
[self updateGutterView];
}
/*
@@ -512,7 +512,7 @@ - (BOOL)showsLineNumbers
*/
- (void)setSyntaxColoured:(BOOL)value
{
- [self setObject:[NSNumber numberWithBool:value] forKey:MGSFOIsSyntaxColoured];
+ [self setObject:@(value) forKey:MGSFOIsSyntaxColoured];
[self reloadString];
}
/*
@@ -657,7 +657,7 @@ - (void) updateGutterView {
NSRect frame, newFrame;
// Update document value first.
- [document setValue:[NSNumber numberWithUnsignedInteger:gutterWidth] forKey:MGSFOGutterWidth];
+ [document setValue:@(gutterWidth) forKey:MGSFOGutterWidth];
// get editor views
NSScrollView *textScrollView = (NSScrollView *)[document valueForKey:ro_MGSFOScrollView];
@@ -711,8 +711,8 @@ + (NSImage *) imageNamed:(NSString *)name
NSBundle* bundle = [NSBundle bundleForClass:[self class]];
NSString *path = [bundle pathForImageResource:name];
- return path != nil ? [[[NSImage alloc]
- initWithContentsOfFile:path] autorelease] : nil;
+ return path != nil ? [[NSImage alloc]
+ initWithContentsOfFile:path] : nil;
}
@end
diff --git a/MGSFragariaFontsAndColoursPrefsViewController.m b/MGSFragariaFontsAndColoursPrefsViewController.m
index e9b2e54c..14504aa8 100644
--- a/MGSFragariaFontsAndColoursPrefsViewController.m
+++ b/MGSFragariaFontsAndColoursPrefsViewController.m
@@ -20,7 +20,7 @@ @implementation MGSFragariaFontsAndColoursPrefsViewController
- init
*/
-- (id)init {
+- (instancetype)init {
self = [super initWithNibName:@"MGSPreferencesFontsAndColours" bundle:[NSBundle bundleForClass:[self class]]];
if (self) {
diff --git a/MGSFragariaPreferences.m b/MGSFragariaPreferences.m
index c4ef9160..ec2dc2b7 100644
--- a/MGSFragariaPreferences.m
+++ b/MGSFragariaPreferences.m
@@ -108,15 +108,15 @@ + (void)initializeValues
[dictionary setValue:[NSArchiver archivedDataWithRootObject:[NSColor colorWithCalibratedRed:0.50f green:0.5f blue:0.2f alpha:1.0f]] forKey:MGSFragariaPrefsAttributesColourWell];
[dictionary setValue:[NSArchiver archivedDataWithRootObject:[NSColor colorWithCalibratedRed:0.031f green:0.0f blue:0.855f alpha:1.0f]] forKey:MGSFragariaPrefsNumbersColourWell];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsColourNumbers];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsColourCommands];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsColourInstructions];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsColourKeywords];
- [dictionary setValue:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsColourAutocomplete];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsColourVariables];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsColourStrings];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsColourAttributes];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsColourComments];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsColourNumbers];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsColourCommands];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsColourInstructions];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsColourKeywords];
+ [dictionary setValue:@NO forKey:MGSFragariaPrefsColourAutocomplete];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsColourVariables];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsColourStrings];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsColourAttributes];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsColourComments];
[dictionary setValue:[NSArchiver archivedDataWithRootObject:[NSColor whiteColor]] forKey:MGSFragariaPrefsBackgroundColourWell];
[dictionary setValue:[NSArchiver archivedDataWithRootObject:[NSColor textColor]] forKey:MGSFragariaPrefsTextColourWell];
@@ -124,39 +124,39 @@ + (void)initializeValues
[dictionary setValue:[NSArchiver archivedDataWithRootObject:[NSColor orangeColor]] forKey:MGSFragariaPrefsInvisibleCharactersColourWell];
[dictionary setValue:[NSArchiver archivedDataWithRootObject:[NSColor colorWithCalibratedRed:0.96f green:0.96f blue:0.71f alpha:1.0f]] forKey:MGSFragariaPrefsHighlightLineColourWell];
- [dictionary setValue:[NSNumber numberWithInteger:40] forKey:MGSFragariaPrefsGutterWidth];
- [dictionary setValue:[NSNumber numberWithInteger:4] forKey:MGSFragariaPrefsTabWidth];
- [dictionary setValue:[NSNumber numberWithInteger:4] forKey:MGSFragariaPrefsIndentWidth];
- [dictionary setValue:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsShowPageGuide];
- [dictionary setValue:[NSNumber numberWithInteger:80] forKey:MGSFragariaPrefsShowPageGuideAtColumn];
- [dictionary setValue:[NSNumber numberWithFloat:1.0f] forKey:MGSFragariaPrefsAutocompleteAfterDelay];
+ [dictionary setValue:@40 forKey:MGSFragariaPrefsGutterWidth];
+ [dictionary setValue:@4 forKey:MGSFragariaPrefsTabWidth];
+ [dictionary setValue:@4 forKey:MGSFragariaPrefsIndentWidth];
+ [dictionary setValue:@NO forKey:MGSFragariaPrefsShowPageGuide];
+ [dictionary setValue:@80 forKey:MGSFragariaPrefsShowPageGuideAtColumn];
+ [dictionary setValue:@1.0f forKey:MGSFragariaPrefsAutocompleteAfterDelay];
[dictionary setValue:[NSArchiver archivedDataWithRootObject:[NSFont fontWithName:@"Menlo" size:11]] forKey:MGSFragariaPrefsTextFont];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsShowFullPathInWindowTitle];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsShowLineNumberGutter];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsSyntaxColourNewDocuments];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsLineWrapNewDocuments];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsIndentNewLinesAutomatically];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsOnlyColourTillTheEndOfLine];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsShowMatchingBraces];
- [dictionary setValue:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsShowInvisibleCharacters];
- [dictionary setValue:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsIndentWithSpaces];
- [dictionary setValue:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsColourMultiLineStrings];
- [dictionary setValue:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsAutocompleteSuggestAutomatically];
- [dictionary setValue:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsAutocompleteIncludeStandardWords];
- [dictionary setValue:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsAutoSpellCheck];
- [dictionary setValue:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsAutoGrammarCheck];
- [dictionary setValue:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsSmartInsertDelete];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsAutomaticLinkDetection];
- [dictionary setValue:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsAutomaticQuoteSubstitution];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsUseTabStops];
- [dictionary setValue:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsHighlightCurrentLine];
- [dictionary setValue:[NSNumber numberWithInteger:4] forKey:MGSFragariaPrefsSpacesPerTabEntabDetab];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsShowFullPathInWindowTitle];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsShowLineNumberGutter];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsSyntaxColourNewDocuments];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsLineWrapNewDocuments];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsIndentNewLinesAutomatically];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsOnlyColourTillTheEndOfLine];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsShowMatchingBraces];
+ [dictionary setValue:@NO forKey:MGSFragariaPrefsShowInvisibleCharacters];
+ [dictionary setValue:@NO forKey:MGSFragariaPrefsIndentWithSpaces];
+ [dictionary setValue:@NO forKey:MGSFragariaPrefsColourMultiLineStrings];
+ [dictionary setValue:@NO forKey:MGSFragariaPrefsAutocompleteSuggestAutomatically];
+ [dictionary setValue:@NO forKey:MGSFragariaPrefsAutocompleteIncludeStandardWords];
+ [dictionary setValue:@NO forKey:MGSFragariaPrefsAutoSpellCheck];
+ [dictionary setValue:@NO forKey:MGSFragariaPrefsAutoGrammarCheck];
+ [dictionary setValue:@NO forKey:MGSFragariaPrefsSmartInsertDelete];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsAutomaticLinkDetection];
+ [dictionary setValue:@NO forKey:MGSFragariaPrefsAutomaticQuoteSubstitution];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsUseTabStops];
+ [dictionary setValue:@NO forKey:MGSFragariaPrefsHighlightCurrentLine];
+ [dictionary setValue:@4 forKey:MGSFragariaPrefsSpacesPerTabEntabDetab];
- [dictionary setValue:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsAutomaticallyIndentBraces];
- [dictionary setValue:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsAutoInsertAClosingParenthesis];
- [dictionary setValue:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsAutoInsertAClosingBrace];
+ [dictionary setValue:@YES forKey:MGSFragariaPrefsAutomaticallyIndentBraces];
+ [dictionary setValue:@NO forKey:MGSFragariaPrefsAutoInsertAClosingParenthesis];
+ [dictionary setValue:@NO forKey:MGSFragariaPrefsAutoInsertAClosingBrace];
[dictionary setValue:@"Standard" forKey:MGSFragariaPrefsSyntaxColouringPopUpString];
[defaultsController setInitialValues:dictionary];
@@ -189,7 +189,7 @@ + (MGSFragariaPreferences *)sharedInstance
+ (id)allocWithZone:(NSZone *)zone
{
#pragma unused(zone)
- return [[self sharedInstance] retain];
+ return [self sharedInstance];
}
#pragma mark -
@@ -200,7 +200,7 @@ + (id)allocWithZone:(NSZone *)zone
- init
*/
-- (id)init
+- (instancetype)init
{
if (sharedInstance) return sharedInstance;
self = [super init];
diff --git a/MGSFragariaTextEditingPrefsViewController.m b/MGSFragariaTextEditingPrefsViewController.m
index aeb33c30..91422f04 100644
--- a/MGSFragariaTextEditingPrefsViewController.m
+++ b/MGSFragariaTextEditingPrefsViewController.m
@@ -20,7 +20,7 @@ @implementation MGSFragariaTextEditingPrefsViewController
- init
*/
-- (id)init {
+- (instancetype)init {
self = [super initWithNibName:@"MGSPreferencesTextEditing" bundle:[NSBundle bundleForClass:[self class]]];
if (self) {
diff --git a/MGSPreferencesController.m b/MGSPreferencesController.m
index d3caab85..ef4fd81c 100644
--- a/MGSPreferencesController.m
+++ b/MGSPreferencesController.m
@@ -22,7 +22,7 @@ @implementation MGSPreferencesController
-initWithWindow: is the designated initializer for NSWindowController.
*/
-- (id)initWithWindow:(NSWindow *)window
+- (instancetype)initWithWindow:(NSWindow *)window
{
#pragma unused(window)
@@ -64,9 +64,9 @@ - (void)setupToolbar
[self addView:generalView label:generalIdentifier];
- [self addView:textEditingPrefsViewController.view label:textIdentifier image:[NSImage imageNamed:@"General.png"]];
+ [self addView:textEditingPrefsViewController.view label:textIdentifier image:[NSImage imageNamed:@"General"]];
- [self addView:fontsAndColoursPrefsViewController.view label:fontIdentifier image:[NSImage imageNamed:@"General.png"]];
+ [self addView:fontsAndColoursPrefsViewController.view label:fontIdentifier image:[NSImage imageNamed:@"General"]];
}
diff --git a/MGSSyntaxController.h b/MGSSyntaxController.h
index 54026a4d..d7632449 100644
--- a/MGSSyntaxController.h
+++ b/MGSSyntaxController.h
@@ -23,6 +23,6 @@
- (NSDictionary *)syntaxDefinitionWithExtension:(NSString *)extension;
- (NSString *)syntaxDefinitionNameWithExtension:(NSString *)extension;
-@property (retain, nonatomic,readonly) NSArray *syntaxDefinitionNames;
+@property (strong, nonatomic,readonly) NSArray *syntaxDefinitionNames;
@end
diff --git a/MGSSyntaxController.m b/MGSSyntaxController.m
index 0c9a1217..38e3eec4 100644
--- a/MGSSyntaxController.m
+++ b/MGSSyntaxController.m
@@ -38,8 +38,8 @@ - (NSDictionary *)standardSyntaxDefinition;
- (NSDictionary *)syntaxDefinitionWithName:(NSString *)name;
- (NSBundle *)bundle;
-@property (retain, nonatomic, readwrite) NSArray *syntaxDefinitionNames;
-@property (retain) NSMutableDictionary *syntaxDefinitions;
+@property (strong, nonatomic, readwrite) NSArray *syntaxDefinitionNames;
+@property (strong) NSMutableDictionary *syntaxDefinitions;
@end
@@ -80,7 +80,7 @@ + (NSString *)standardSyntaxDefinitionName
- init
*/
-- (id)init
+- (instancetype)init
{
if (sharedInstance == nil) {
self = [super init];
@@ -102,7 +102,7 @@ - (NSDictionary *)standardSyntaxDefinition
{
// key is lowercase name
NSString *name = [[self class] standardSyntaxDefinitionName];
- NSDictionary *definition = [self.syntaxDefinitions objectForKey:[name lowercaseString]];
+ NSDictionary *definition = (self.syntaxDefinitions)[[name lowercaseString]];
NSAssert(definition, @"standard syntax definition not found");
return definition;
}
@@ -115,7 +115,7 @@ - (NSDictionary *)standardSyntaxDefinition
- (NSDictionary *)syntaxDefinitionWithName:(NSString *)name
{
// key is lowercase name
- NSDictionary *definition = [self.syntaxDefinitions objectForKey:[name lowercaseString]];
+ NSDictionary *definition = (self.syntaxDefinitions)[[name lowercaseString]];
if (!definition) {
definition = [self standardSyntaxDefinition];
}
@@ -180,9 +180,9 @@ - (void)insertSyntaxDefinitions
NSMutableArray *syntaxDefinitionsArray = [self loadSyntaxDefinitions];
// add Standard and None definitions
- NSArray *keys = [NSArray arrayWithObjects:@"name", @"file", @"extensions", nil];
- NSDictionary *standard = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"Standard", @"standard", [NSString string], nil] forKeys:keys];
- NSDictionary *none = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"None", @"none", [NSString string], nil] forKeys:keys];
+ NSArray *keys = @[@"name", @"file", @"extensions"];
+ NSDictionary *standard = [NSDictionary dictionaryWithObjects:@[@"Standard", @"standard", [NSString string]] forKeys:keys];
+ NSDictionary *none = [NSDictionary dictionaryWithObjects:@[@"None", @"none", [NSString string]] forKeys:keys];
[syntaxDefinitionsArray insertObject:none atIndex:0];
[syntaxDefinitionsArray insertObject:standard atIndex:0];
@@ -206,15 +206,15 @@ - (void)insertSyntaxDefinitions
id syntaxDefinition = [NSMutableDictionary dictionaryWithCapacity:6];
[syntaxDefinition setValue:name forKey:@"name"];
[syntaxDefinition setValue:[item valueForKey:@"file"] forKey:@"file"];
- [syntaxDefinition setValue:[NSNumber numberWithInteger:idx] forKey:@"sortOrder"];
+ [syntaxDefinition setValue:@(idx) forKey:@"sortOrder"];
idx++;
// key is lowercase name
- [self.syntaxDefinitions setObject:syntaxDefinition forKey:[name lowercaseString]];
+ (self.syntaxDefinitions)[[name lowercaseString]] = syntaxDefinition;
[definitionNames addObject:name];
}
- self.syntaxDefinitionNames = [[definitionNames copy] autorelease];
+ self.syntaxDefinitionNames = [definitionNames copy];
}
@@ -248,7 +248,7 @@ - (NSMutableArray *)loadSyntaxDefinitions
[self addSyntaxDefinitions:syntaxDefinitionsArray path:path];
// load syntax definitions from application support
- NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
+ NSString *appName = [[NSBundle mainBundle] infoDictionary][@"CFBundleName"];
path = [[[[NSHomeDirectory() stringByAppendingPathComponent:@"Library"] stringByAppendingPathComponent:@"Application Support"] stringByAppendingPathComponent:appName] stringByAppendingPathComponent:kMGSSyntaxDefinitionsFile];
[self addSyntaxDefinitions:syntaxDefinitionsArray path:path];
@@ -269,20 +269,20 @@ - (NSDictionary *)syntaxDictionaryWithName:(NSString *)name
NSDictionary *definition = [self syntaxDefinitionWithName:name];
for (NSInteger i = 0; i <= 1; i++) {
- NSString *fileName = [definition objectForKey:@"file"];
+ NSString *fileName = definition[@"file"];
// load dictionary from this bundle
- NSDictionary *syntaxDictionary = [[[NSDictionary alloc] initWithContentsOfFile:[[self bundle] pathForResource:fileName ofType:KMGSSyntaxDefinitionsExt inDirectory:KMGSSyntaxDefinitionsFolder]] autorelease];
+ NSDictionary *syntaxDictionary = [[NSDictionary alloc] initWithContentsOfFile:[[self bundle] pathForResource:fileName ofType:KMGSSyntaxDefinitionsExt inDirectory:KMGSSyntaxDefinitionsFolder]];
if (syntaxDictionary) return syntaxDictionary;
// load dictionary from main bundle
- syntaxDictionary = [[[NSDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:fileName ofType:KMGSSyntaxDefinitionsExt inDirectory:KMGSSyntaxDefinitionsFolder]] autorelease];
+ syntaxDictionary = [[NSDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:fileName ofType:KMGSSyntaxDefinitionsExt inDirectory:KMGSSyntaxDefinitionsFolder]];
if (syntaxDictionary) return syntaxDictionary;
// load from application support
- NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
+ NSString *appName = [[NSBundle mainBundle] infoDictionary][@"CFBundleName"];
NSString *path = [[[[[NSHomeDirectory() stringByAppendingPathComponent:@"Library"] stringByAppendingPathComponent:@"Application Support"] stringByAppendingPathComponent:appName] stringByAppendingPathComponent:fileName] stringByAppendingString:KMGSSyntaxDictionaryExt];
- syntaxDictionary = [[[NSDictionary alloc] initWithContentsOfFile:path] autorelease];
+ syntaxDictionary = [[NSDictionary alloc] initWithContentsOfFile:path];
if (syntaxDictionary) return syntaxDictionary;
// no dictionary found so use standard definition
@@ -299,7 +299,7 @@ - (NSDictionary *)syntaxDictionaryWithName:(NSString *)name
- (void)addSyntaxDefinitions:(NSMutableArray *)definitions path:(NSString *)path
{
if ([[NSFileManager defaultManager] fileExistsAtPath:path] == YES) {
- [definitions addObjectsFromArray:[[[NSArray alloc] initWithContentsOfFile:path] autorelease]];
+ [definitions addObjectsFromArray:[[NSArray alloc] initWithContentsOfFile:path]];
}
}
diff --git a/MGSTextMenuController.m b/MGSTextMenuController.m
index cfa8d5fe..63355f11 100644
--- a/MGSTextMenuController.m
+++ b/MGSTextMenuController.m
@@ -58,7 +58,7 @@ + (MGSTextMenuController *)sharedInstance
+ (id)allocWithZone:(NSZone *)zone
{
#pragma unused(zone)
- return [[self sharedInstance] retain];
+ return [self sharedInstance];
}
#pragma mark -
@@ -69,7 +69,7 @@ + (id)allocWithZone:(NSZone *)zone
- init
*/
-- (id)init
+- (instancetype)init
{
if (sharedInstance == nil) {
sharedInstance = [super init];
@@ -86,7 +86,7 @@ - (id)init
- (void)setEdited:(BOOL)aBool
{
if ([[SMLCurrentDocument valueForKey:MGSFOIsEdited] boolValue] != aBool) {
- [[MGSFragaria currentInstance] setObject:[NSNumber numberWithBool:aBool] forKey:MGSFOIsEdited];
+ [MGSFragaria currentInstance][MGSFOIsEdited] = @(aBool);
}
}
@@ -126,7 +126,7 @@ - (void)buildEncodingsMenus
for (item in enumerator) {
if ([[item valueForKey:@"active"] boolValue] == YES) {
NSUInteger encoding = [[item valueForKey:@"encoding"] unsignedIntegerValue];
- menuItem = [[[NSMenuItem alloc] initWithTitle:[NSString localizedNameOfStringEncoding:encoding] action:@selector(changeEncodingAction:) keyEquivalent:@""] autorelease];
+ menuItem = [[NSMenuItem alloc] initWithTitle:[NSString localizedNameOfStringEncoding:encoding] action:@selector(changeEncodingAction:) keyEquivalent:@""];
[menuItem setTag:encoding];
[menuItem setTarget:self];
[textEncodingMenu insertItem:menuItem atIndex:0];
@@ -137,7 +137,7 @@ - (void)buildEncodingsMenus
for (item in enumerator) {
if ([[item valueForKey:@"active"] boolValue] == YES) {
NSUInteger encoding = [[item valueForKey:@"encoding"] unsignedIntegerValue];
- menuItem = [[[NSMenuItem alloc] initWithTitle:[NSString localizedNameOfStringEncoding:encoding] action:@selector(reloadText:) keyEquivalent:@""] autorelease];
+ menuItem = [[NSMenuItem alloc] initWithTitle:[NSString localizedNameOfStringEncoding:encoding] action:@selector(reloadText:) keyEquivalent:@""];
[menuItem setTag:encoding];
[menuItem setTarget:self];
[reloadTextWithEncodingMenu insertItem:menuItem atIndex:0];
@@ -157,7 +157,7 @@ - (void)buildSyntaxDefinitionsMenu
NSMenuItem *menuItem;
NSInteger tag = [syntaxDefinitions count] - 1;
for (id item in enumerator) {
- menuItem = [[[NSMenuItem alloc] initWithTitle:[item valueForKey:@"name"] action:@selector(changeSyntaxDefinitionAction:) keyEquivalent:@""] autorelease];
+ menuItem = [[NSMenuItem alloc] initWithTitle:[item valueForKey:@"name"] action:@selector(changeSyntaxDefinitionAction:) keyEquivalent:@""];
[menuItem setTag:tag];
[menuItem setTarget:self];
[syntaxDefinitionMenu insertItem:menuItem atIndex:0];
@@ -236,10 +236,10 @@ - (void)changeEncodingAction:(id)sender
id document = SMLCurrentDocument;
- [[[document valueForKey:ro_MGSFOSyntaxColouring] undoManager] registerUndoWithTarget:self selector:@selector(performUndoChangeEncoding:) object:[NSArray arrayWithObject:[document valueForKey:@"encoding"]]];
+ [[[document valueForKey:ro_MGSFOSyntaxColouring] undoManager] registerUndoWithTarget:self selector:@selector(performUndoChangeEncoding:) object:@[[document valueForKey:@"encoding"]]];
[[[document valueForKey:ro_MGSFOSyntaxColouring] undoManager] setActionName:NAME_FOR_UNDO_CHANGE_ENCODING];
- [document setValue:[NSNumber numberWithInteger:encoding] forKey:@"encoding"];
+ [document setValue:[NSNumber numberWithInteger:(long)encoding] forKey:@"encoding"];
[document setValue:[NSString localizedNameOfStringEncoding:encoding] forKey:@"encodingName"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"MGSFragariaTextEncodingChanged" object:[MGSFragaria currentInstance] userInfo:nil];
@@ -254,11 +254,11 @@ -(void)performUndoChangeEncoding:(id)sender
{
id document = SMLCurrentDocument;
- [[[document valueForKey:ro_MGSFOSyntaxColouring] undoManager] registerUndoWithTarget:self selector:@selector(performUndoChangeEncoding:) object:[NSArray arrayWithObject:[document valueForKey:@"encoding"]]];
+ [[[document valueForKey:ro_MGSFOSyntaxColouring] undoManager] registerUndoWithTarget:self selector:@selector(performUndoChangeEncoding:) object:@[[document valueForKey:@"encoding"]]];
[[[document valueForKey:ro_MGSFOSyntaxColouring] undoManager] setActionName:NAME_FOR_UNDO_CHANGE_ENCODING];
- [document setValue:[sender objectAtIndex:0] forKey:@"encoding"];
- [document setValue:[NSString localizedNameOfStringEncoding:[[sender objectAtIndex:0] unsignedIntegerValue]] forKey:@"encodingName"];
+ [document setValue:sender[0] forKey:@"encoding"];
+ [document setValue:[NSString localizedNameOfStringEncoding:[sender[0] unsignedIntegerValue]] forKey:@"encodingName"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"MGSFragariaTextEncodingChanged" object:[MGSFragaria currentInstance] userInfo:nil];
@@ -1160,10 +1160,10 @@ - (IBAction)changeLineEndingsAction:(id)sender
{
id document = SMLCurrentDocument;
- [[[document valueForKey:ro_MGSFOSyntaxColouring] undoManager] registerUndoWithTarget:self selector:@selector(performUndoChangeLineEndings:) object:[NSArray arrayWithObject:[document valueForKey:@"lineEndings"]]];
+ [[[document valueForKey:ro_MGSFOSyntaxColouring] undoManager] registerUndoWithTarget:self selector:@selector(performUndoChangeLineEndings:) object:@[[document valueForKey:@"lineEndings"]]];
[[[document valueForKey:ro_MGSFOSyntaxColouring] undoManager] setActionName:NAME_FOR_UNDO_CHANGE_LINE_ENDINGS];
- [document setValue:[NSNumber numberWithInteger:[sender tag] - 150] forKey:@"lineEndings"];
+ [document setValue:@([sender tag] - 150) forKey:@"lineEndings"];
NSTextView *textView = SMLCurrentTextView;
NSRange selectedRange = [textView selectedRange];
@@ -1186,10 +1186,10 @@ - (void)performUndoChangeLineEndings:(id)sender
{
id document = SMLCurrentDocument;
- [[[document valueForKey:ro_MGSFOSyntaxColouring] undoManager] registerUndoWithTarget:self selector:@selector(performUndoChangeLineEndings:) object:[NSArray arrayWithObject:[document valueForKey:@"lineEndings"]]];
+ [[[document valueForKey:ro_MGSFOSyntaxColouring] undoManager] registerUndoWithTarget:self selector:@selector(performUndoChangeLineEndings:) object:@[[document valueForKey:@"lineEndings"]]];
[[[document valueForKey:ro_MGSFOSyntaxColouring] undoManager] setActionName:NAME_FOR_UNDO_CHANGE_LINE_ENDINGS];
- [document setValue:[sender objectAtIndex:0] forKey:@"lineEndings"];
+ [document setValue:sender[0] forKey:@"lineEndings"];
NSTextView *textView = SMLCurrentTextView;
NSRange selectedRange = [textView selectedRange];
@@ -1215,7 +1215,7 @@ - (IBAction)changeSyntaxDefinitionAction:(id)sender
{
id document = SMLCurrentDocument;
[document setValue:[sender title] forKey:MGSFOSyntaxDefinitionName];
- [document setValue:[NSNumber numberWithBool:YES] forKey:@"hasManuallyChangedSyntaxDefinition"];
+ [document setValue:@YES forKey:@"hasManuallyChangedSyntaxDefinition"];
[[document valueForKey:ro_MGSFOSyntaxColouring] applySyntaxDefinition];
[[document valueForKey:ro_MGSFOSyntaxColouring] pageRecolour];
diff --git a/MyDocument.h b/MyDocument.h
index 8a6936aa..63636b9b 100644
--- a/MyDocument.h
+++ b/MyDocument.h
@@ -17,7 +17,6 @@
BOOL isEdited;
}
-- (void)setSyntaxDefinition:(NSString *)name;
-- (NSString *)syntaxDefinition;
+@property (NS_NONATOMIC_IOSONLY, copy) NSString *syntaxDefinition;
@end
diff --git a/MyDocument.m b/MyDocument.m
index 305eef6f..79c381ed 100644
--- a/MyDocument.m
+++ b/MyDocument.m
@@ -16,7 +16,7 @@ @implementation MyDocument
- init
*/
-- (id)init
+- (instancetype)init
{
self = [super init];
if (self) {
@@ -69,8 +69,8 @@ - (void)windowControllerDidLoadNib:(NSWindowController *) aController
// see MGSFragariaPreferences.h for details
//
if (NO) {
- [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:MGSFragariaPrefsAutocompleteSuggestAutomatically];
- [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:NO] forKey:MGSFragariaPrefsLineWrapNewDocuments];
+ [[NSUserDefaults standardUserDefaults] setObject:@YES forKey:MGSFragariaPrefsAutocompleteSuggestAutomatically];
+ [[NSUserDefaults standardUserDefaults] setObject:@NO forKey:MGSFragariaPrefsLineWrapNewDocuments];
}
// define initial document configuration
@@ -78,8 +78,8 @@ - (void)windowControllerDidLoadNib:(NSWindowController *) aController
// see MGSFragaria.h for details
//
if (YES) {
- [fragaria setObject:[NSNumber numberWithBool:YES] forKey:MGSFOIsSyntaxColoured];
- [fragaria setObject:[NSNumber numberWithBool:YES] forKey:MGSFOShowLineNumberGutter];
+ [fragaria setObject:@YES forKey:MGSFOIsSyntaxColoured];
+ [fragaria setObject:@YES forKey:MGSFOShowLineNumberGutter];
}
// set text
@@ -176,7 +176,7 @@ - (void)textDidChange:(NSNotification *)notification
{
#pragma unused(notification)
- NSWindow *window = [[self windowControllers] objectAtIndex:0];
+ NSWindow *window = [self windowControllers][0];
[window setDocumentEdited:YES];
}
diff --git a/NSStringICUAdditions.h b/NSStringICUAdditions.h
index d45afec5..14a6924d 100644
--- a/NSStringICUAdditions.h
+++ b/NSStringICUAdditions.h
@@ -32,7 +32,7 @@
other words, if you want to keep this string around beyond the given autorelease
context, you need to copy the returned string.
*/
--(void *)UTF16String;
+@property (NS_NONATOMIC_IOSONLY, readonly) void *UTF16String;
/*!
@@ -41,7 +41,7 @@
@discussion Returns a UTF16 encoded string in the native encoding. The returned
buffer must eventually be freed.
*/
--(void *)copyUTF16String;
+@property (NS_NONATOMIC_IOSONLY, readonly) void *copyUTF16String;
/*!
@method findPattern:
diff --git a/NSStringICUAdditions.m b/NSStringICUAdditions.m
index 4f2dfa48..226d1c0e 100644
--- a/NSStringICUAdditions.m
+++ b/NSStringICUAdditions.m
@@ -60,9 +60,9 @@ -(NSArray *)componentsSeparatedByPattern:(NSString *)aRegex {
}
+(NSString *)stringWithICUString:(void *)utf16EncodedString {
- return [[[NSString alloc] initWithBytes:utf16EncodedString
- length:u_strlen(utf16EncodedString)*sizeof(UChar)
- encoding:[self nativeUTF16Encoding]] autorelease];
+ return [[NSString alloc] initWithBytes:utf16EncodedString
+ length:u_strlen(utf16EncodedString)*sizeof(UChar)
+ encoding:[self nativeUTF16Encoding]];
}
+(NSStringEncoding)nativeUTF16Encoding {
diff --git a/SMLBasicPerformer.m b/SMLBasicPerformer.m
index 50bdb97e..bee1055a 100644
--- a/SMLBasicPerformer.m
+++ b/SMLBasicPerformer.m
@@ -119,7 +119,7 @@ - (NSString *)newUUID
CFStringRef uuidString = CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);
- return NSMakeCollectable(uuidString);
+ return (__bridge NSString *)(NSAllocateCollectable(uuidString, NSScannedOption));
}
/*
@@ -132,7 +132,7 @@ - (void)insertSortOrderNumbersForArrayController:(NSArrayController *)arrayContr
NSArray *array = [arrayController arrangedObjects];
NSInteger idx = 0;
for (id item in array) {
- [item setValue:[NSNumber numberWithInteger:idx] forKey:@"sortOrder"];
+ [item setValue:@(idx) forKey:@"sortOrder"];
idx++;
}
}
@@ -165,7 +165,7 @@ - (NSString *)copyResolveAliasInPath:(NSString *)path
if (FSResolveAliasFile (&fsRef, true, &targetIsFolder, &wasAliased) == noErr && wasAliased) {
CFURLRef resolvedURL = CFURLCreateFromFSRef(NULL, &fsRef);
if (resolvedURL != NULL) {
- resolvedPath = (NSString*)CFURLCopyFileSystemPath(resolvedURL, kCFURLPOSIXPathStyle);
+ resolvedPath = (NSString*)CFBridgingRelease(CFURLCopyFileSystemPath(resolvedURL, kCFURLPOSIXPathStyle));
CFRelease(resolvedURL);
}
}
@@ -177,7 +177,7 @@ - (NSString *)copyResolveAliasInPath:(NSString *)path
return path;
}
- return NSMakeCollectable(resolvedPath);
+ return (__bridge NSString *)(NSAllocateCollectable(resolvedPath, NSScannedOption));
}
@end
diff --git a/SMLErrorPopOver.m b/SMLErrorPopOver.m
index 47827a2c..82cf8d27 100644
--- a/SMLErrorPopOver.m
+++ b/SMLErrorPopOver.m
@@ -13,8 +13,8 @@
@implementation SMLErrorPopOver
+ (CGFloat) widthOfString:(NSString *)string withFont:(NSFont *)font {
- NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil];
- return [[[[NSAttributedString alloc] initWithString:string attributes:attributes] autorelease] size].width;
+ NSDictionary *attributes = @{NSFontAttributeName: font};
+ return [[[NSAttributedString alloc] initWithString:string attributes:attributes] size].width;
}
+ (void) showErrorDescriptions:(NSArray*)errors relativeToView:(NSView*) view
@@ -28,7 +28,7 @@ + (void) showErrorDescriptions:(NSArray*)errors relativeToView:(NSView*) view
if (!numErrors) return;
// Create view controller
- NSViewController* vc = [[[NSViewController alloc] initWithNibName:@"ErrorPopoverView" bundle:[NSBundle bundleForClass:[self class]]] autorelease];
+ NSViewController* vc = [[NSViewController alloc] initWithNibName:@"ErrorPopoverView" bundle:[NSBundle bundleForClass:[self class]]];
// Create labels and add them to the view
for (NSString* err in errors)
@@ -40,7 +40,7 @@ + (void) showErrorDescriptions:(NSArray*)errors relativeToView:(NSView*) view
int width = [self widthOfString:err withFont:font];
if (width > maxWidth) maxWidth = width;
- textField = [[[NSTextField alloc] initWithFrame:NSMakeRect(0, viewHeight - (kSMLErrorPopOverErrorSpacing * (errNo + 1)), 1024, kSMLErrorPopOverErrorSpacing)] autorelease];
+ textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, viewHeight - (kSMLErrorPopOverErrorSpacing * (errNo + 1)), 1024, kSMLErrorPopOverErrorSpacing)];
[textField setStringValue:err.description];
[textField setBezeled:NO];
[textField setDrawsBackground:NO];
@@ -56,7 +56,7 @@ + (void) showErrorDescriptions:(NSArray*)errors relativeToView:(NSView*) view
[vc.view setFrameSize:NSMakeSize(maxWidth, viewHeight)];
// Open the popover
- NSPopover* popover = [[[NSPopover alloc] init] autorelease];
+ NSPopover* popover = [[NSPopover alloc] init];
popover.behavior = NSPopoverBehaviorTransient;
popover.contentSize = vc.view.bounds.size;
popover.contentViewController = vc;
diff --git a/SMLGutterTextView.h b/SMLGutterTextView.h
index 52347092..65fea159 100644
--- a/SMLGutterTextView.h
+++ b/SMLGutterTextView.h
@@ -29,6 +29,6 @@ Unless required by applicable law or agreed to in writing, software distributed
}
@property (nonatomic,copy) NSString* fileName;
-@property (nonatomic,retain) NSArray* breakpointLines;
+@property (nonatomic,strong) NSArray* breakpointLines;
@end
diff --git a/SMLGutterTextView.m b/SMLGutterTextView.m
index ecc62801..37c212ea 100644
--- a/SMLGutterTextView.m
+++ b/SMLGutterTextView.m
@@ -38,15 +38,9 @@ - (id)initWithFrame:(NSRect)frame
{
if ((self = [super initWithFrame:frame])) {
- imgBreakpoint0 = [MGSFragaria imageNamed:@"editor-breakpoint-0.png"];
- [imgBreakpoint0 setFlipped:YES];
- [imgBreakpoint0 retain];
- imgBreakpoint1 = [MGSFragaria imageNamed:@"editor-breakpoint-1.png"];
- [imgBreakpoint1 setFlipped:YES];
- [imgBreakpoint1 retain];
- imgBreakpoint2 = [MGSFragaria imageNamed:@"editor-breakpoint-2.png"];
- [imgBreakpoint2 setFlipped:YES];
- [imgBreakpoint2 retain];
+ imgBreakpoint0 = [MGSFragaria imageNamed:@"editor-breakpoint-0"];
+ imgBreakpoint1 = [MGSFragaria imageNamed:@"editor-breakpoint-1"];
+ imgBreakpoint2 = [MGSFragaria imageNamed:@"editor-breakpoint-2"];
[self setContinuousSpellCheckingEnabled:NO];
[self setAllowsUndo:NO];
@@ -76,16 +70,14 @@ - (id)initWithFrame:(NSRect)frame
Does line wrapping make the issue worse?
*/
- NSMutableParagraphStyle * style = [[[NSMutableParagraphStyle alloc] init] autorelease];
+ NSMutableParagraphStyle * style = [[NSMutableParagraphStyle alloc] init];
[style setAlignment:NSRightTextAlignment];
[style setLineSpacing:1.0];
[style setMinimumLineHeight:11.0];
[style setMaximumLineHeight:11.0];
[self setDefaultParagraphStyle:style];
- [self setTypingAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
- [self defaultParagraphStyle], NSParagraphStyleAttributeName,
- nil]];
+ [self setTypingAttributes: @{NSParagraphStyleAttributeName: [self defaultParagraphStyle]}];
}
[self setFont:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextFont]]];
@@ -109,7 +101,7 @@ - (id)initWithFrame:(NSRect)frame
*/
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
- if ([(NSString *)context isEqualToString:@"TextFontChanged"]) {
+ if ([(__bridge NSString *)context isEqualToString:@"TextFontChanged"]) {
[self setFont:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextFont]]];
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
@@ -170,13 +162,13 @@ - (void)mouseDown:(NSEvent *)theEvent
int lineNum = [substring intValue];
- id delegate = [[MGSFragaria currentInstance] objectForKey:MGSFOBreakpointDelegate];
+ id delegate = [MGSFragaria currentInstance][MGSFOBreakpointDelegate];
if (delegate && [delegate respondsToSelector:@selector(toggleBreakpointForFile:onLine:)])
{
[delegate toggleBreakpointForFile:self.fileName onLine:lineNum];
}
- SMLLineNumbers* lineNumbers = [[MGSFragaria currentInstance] objectForKey:ro_MGSFOLineNumbers];
+ SMLLineNumbers* lineNumbers = [MGSFragaria currentInstance][ro_MGSFOLineNumbers];
[lineNumbers updateLineNumbersCheckWidth:NO recolour:NO];
[self setNeedsDisplay:YES];
@@ -220,14 +212,5 @@ - (BOOL)isOpaque
return YES;
}
-- (void) dealloc
-{
- [imgBreakpoint0 release];
- [imgBreakpoint1 release];
- [imgBreakpoint2 release];
- self.fileName = NULL;
- self.breakpointLines = NULL;
- [super dealloc];
-}
@end
diff --git a/SMLLayoutManager.h b/SMLLayoutManager.h
index 759be7c3..ffdfeaa3 100644
--- a/SMLLayoutManager.h
+++ b/SMLLayoutManager.h
@@ -32,7 +32,7 @@ Unless required by applicable law or agreed to in writing, software distributed
NSMutableArray *lineRefs;
}
-- (NSAttributedString *)attributedStringWithTemporaryAttributesApplied;
+@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSAttributedString *attributedStringWithTemporaryAttributesApplied;
@property BOOL showInvisibleCharacters;
diff --git a/SMLLayoutManager.m b/SMLLayoutManager.m
index 17827bff..7e6173ab 100644
--- a/SMLLayoutManager.m
+++ b/SMLLayoutManager.m
@@ -72,7 +72,7 @@ - (id)init
// assign our custom glyph generator
if (useGlyphSubstitutionForInvisibleGlyphs) {
- [self setGlyphGenerator:[[[MGSGlyphGenerator alloc] init] autorelease]];
+ [self setGlyphGenerator:[[MGSGlyphGenerator alloc] init]];
}
}
@@ -88,10 +88,10 @@ - (id)init
*/
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
- if ([(NSString *)context isEqualToString:@"FontOrColourValueChanged"]) {
+ if ([(__bridge NSString *)context isEqualToString:@"FontOrColourValueChanged"]) {
[self resetAttributesAndGlyphs];
[[self firstTextView] setNeedsDisplay:YES];
- } else if ([(NSString *)context isEqualToString:@"InvisibleCharacterValueChanged"]) {
+ } else if ([(__bridge NSString *)context isEqualToString:@"InvisibleCharacterValueChanged"]) {
[self setShowInvisibleCharacters:[[SMLDefaults valueForKey:MGSFragariaPrefsShowInvisibleCharacters] boolValue]];
if (useGlyphSubstitutionForInvisibleGlyphs) {
@@ -197,7 +197,7 @@ - (void)drawGlyphsForGlyphRange:(NSRange)glyphRange atPoint:(NSPoint)containerOr
pointToDrawAt.y += glyphFragment.origin.y;
// get our text line object
- CTLineRef line = (CTLineRef)[lineRefs objectAtIndex:lineRefIndex];
+ CTLineRef line = (__bridge CTLineRef)lineRefs[lineRefIndex];
CGContextSetTextPosition(gcContext, pointToDrawAt.x, pointToDrawAt.y);
CTLineDraw(line, gcContext);
@@ -328,7 +328,7 @@ - (NSAttributedString *)attributedStringWithTemporaryAttributesApplied
*/
- NSMutableAttributedString *attributedString = [[[self attributedString] mutableCopy] autorelease];
+ NSMutableAttributedString *attributedString = [[self attributedString] mutableCopy];
NSInteger lastCharacter = [attributedString length];
[self removeTemporaryAttribute:NSBackgroundColorAttributeName forCharacterRange:NSMakeRange(0, lastCharacter)];
@@ -356,37 +356,31 @@ - (NSAttributedString *)attributedStringWithTemporaryAttributesApplied
- (void)resetAttributesAndGlyphs
{
// assemble our default attributes
- [defAttributes release];
- defAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
- [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextFont]], NSFontAttributeName, [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsInvisibleCharactersColourWell]], NSForegroundColorAttributeName, nil];
+ defAttributes = @{NSFontAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextFont]], NSForegroundColorAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsInvisibleCharactersColourWell]]};
// define substitute characters for whitespace chars
unichar tabUnichar = 0x00AC;
- [tabCharacter release];
tabCharacter = [[NSString alloc] initWithCharacters:&tabUnichar length:1];
unichar newLineUnichar = 0x00B6;
- [newLineCharacter release];
newLineCharacter = [[NSString alloc] initWithCharacters:&newLineUnichar length:1];
- [spaceCharacter release];
spaceCharacter = @".";
if (drawInvisibleGlyphsUsingCoreText) {
// all CFTypes can be added to NS collections
// http://www.mikeash.com/pyblog/friday-qa-2010-01-22-toll-free-bridging-internals.html
- [lineRefs release];
- lineRefs = [[NSMutableArray arrayWithCapacity:kNewLineLine+1] retain];
+ lineRefs = [NSMutableArray arrayWithCapacity:kNewLineLine+1];
- NSAttributedString *attrString = [[[NSAttributedString alloc] initWithString:tabCharacter attributes:defAttributes] autorelease];
- CTLineRef textLine = CFMakeCollectable(CTLineCreateWithAttributedString((CFAttributedStringRef)attrString));
- [lineRefs addObject:(id)textLine]; // kTabLine
-
- attrString = [[[NSAttributedString alloc] initWithString:spaceCharacter attributes:defAttributes] autorelease];
- textLine = CFMakeCollectable(CTLineCreateWithAttributedString((CFAttributedStringRef)attrString));
- [lineRefs addObject:(id)textLine]; // kSpaceLine
+ NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:tabCharacter attributes:defAttributes];
+ CTLineRef textLine = CTLineCreateWithAttributedString((CFAttributedStringRef)attrString);
+ [lineRefs addObject:(__bridge id)textLine]; // kTabLine
+
+ attrString = [[NSAttributedString alloc] initWithString:spaceCharacter attributes:defAttributes];
+ textLine = CTLineCreateWithAttributedString((CFAttributedStringRef)attrString);
+ [lineRefs addObject:(__bridge id)textLine]; // kSpaceLine
- attrString = [[[NSAttributedString alloc] initWithString:newLineCharacter attributes:defAttributes] autorelease];
- textLine = CFMakeCollectable(CTLineCreateWithAttributedString((CFAttributedStringRef)attrString));
- [lineRefs addObject:(id)textLine]; // kNewLineLine
+ attrString = [[NSAttributedString alloc] initWithString:newLineCharacter attributes:defAttributes];
+ textLine = CTLineCreateWithAttributedString((CFAttributedStringRef)attrString);
+ [lineRefs addObject:(__bridge id)textLine]; // kNewLineLine
}
// experimental glyph substitution
@@ -395,10 +389,10 @@ - (void)resetAttributesAndGlyphs
NSString *glyphString = [NSString stringWithFormat:@"%@%@%@", tabCharacter, spaceCharacter, newLineCharacter];
// use NSLayoutManager instance to generate required glyphs using the default attributes
- NSTextStorage *textStorage = [[[NSTextStorage alloc] initWithString:glyphString] autorelease];
+ NSTextStorage *textStorage = [[NSTextStorage alloc] initWithString:glyphString];
[textStorage setAttributes:defAttributes range:NSMakeRange(0, [glyphString length])];
- NSLayoutManager *layoutManager = [[[NSLayoutManager alloc] init] autorelease];
- NSTextContainer *textContainer = [[[NSTextContainer alloc] init] autorelease];
+ NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
+ NSTextContainer *textContainer = [[NSTextContainer alloc] init];
[layoutManager addTextContainer:textContainer];
[textStorage addLayoutManager:layoutManager];
diff --git a/SMLLineNumbers.h b/SMLLineNumbers.h
index 093511a3..cc4dae67 100644
--- a/SMLLineNumbers.h
+++ b/SMLLineNumbers.h
@@ -28,7 +28,7 @@ Unless required by applicable law or agreed to in writing, software distributed
id document;
}
-- (id)initWithDocument:(id)theDocument;
+- (instancetype)initWithDocument:(id)theDocument;
- (void)viewBoundsDidChange:(NSNotification *)notification;
- (void)updateLineNumbersCheckWidth:(BOOL)checkWidth recolour:(BOOL)recolour;
- (void)updateLineNumbersForClipView:(NSClipView *)clipView checkWidth:(BOOL)checkWidth recolour:(BOOL)recolour;
diff --git a/SMLLineNumbers.m b/SMLLineNumbers.m
index ae7f0390..0ec2708a 100644
--- a/SMLLineNumbers.m
+++ b/SMLLineNumbers.m
@@ -21,9 +21,9 @@
#import "MGSFragariaFramework.h"
@interface SMLLineNumbers()
-@property (retain) NSDictionary *attributes;
-@property (retain) id document;
-@property (retain) NSClipView *updatingLineNumbersForClipView;
+@property (strong) NSDictionary *attributes;
+@property (strong) id document;
+@property (strong) NSClipView *updatingLineNumbersForClipView;
@end
@@ -58,7 +58,7 @@ - (id)initWithDocument:(id)theDocument
self.document = theDocument;
zeroPoint = NSMakePoint(0, 0);
- self.attributes = [[[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextFont]], NSFontAttributeName, nil] autorelease];
+ self.attributes = @{NSFontAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextFont]]};
NSUserDefaultsController *defaultsController = [NSUserDefaultsController sharedUserDefaultsController];
[defaultsController addObserver:self forKeyPath:@"values.FragariaTextFont" options:NSKeyValueObservingOptionNew context:@"TextFontChanged"];
}
@@ -75,8 +75,8 @@ - (id)initWithDocument:(id)theDocument
*/
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
- if ([(NSString *)context isEqualToString:@"TextFontChanged"]) {
- self.attributes = [[[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextFont]], NSFontAttributeName, nil] autorelease];
+ if ([(__bridge NSString *)context isEqualToString:@"TextFontChanged"]) {
+ self.attributes = @{NSFontAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextFont]]};
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
@@ -149,7 +149,7 @@ - (void)updateLineNumbersForClipView:(NSClipView *)clipView checkWidth:(BOOL)che
// get break points from delegate
NSSet* breakpoints = NULL;
- id breakpointDelegate = [[MGSFragaria currentInstance] objectForKey:MGSFOBreakpointDelegate];
+ id breakpointDelegate = [MGSFragaria currentInstance][MGSFOBreakpointDelegate];
if (breakpointDelegate && [breakpointDelegate respondsToSelector:@selector(breakpointsForFile:)])
{
breakpoints = [breakpointDelegate breakpointsForFile:[gutterScrollView.documentView fileName]];
@@ -177,7 +177,7 @@ - (void)updateLineNumbersForClipView:(NSClipView *)clipView checkWidth:(BOOL)che
oneMoreTime = YES; // Continue one more time through the loop if the last glyph isn't newline
}
}
- NSMutableString *lineNumbersString = [[[NSMutableString alloc] init] autorelease];
+ NSMutableString *lineNumbersString = [[NSMutableString alloc] init];
int textLine = 0;
NSMutableArray* textLineBreakpoints = [NSMutableArray array];
@@ -192,9 +192,9 @@ - (void)updateLineNumbersForClipView:(NSClipView *)clipView checkWidth:(BOOL)che
textLine++;
// flag breakpoints
- if ([breakpoints containsObject:[NSNumber numberWithInt:(int)lineNumber]])
+ if ([breakpoints containsObject:@((int)lineNumber)])
{
- [textLineBreakpoints addObject:[NSNumber numberWithInt:textLine]];
+ [textLineBreakpoints addObject:@(textLine)];
}
} else {
[lineNumbersString appendFormat:@"%C\n", (unsigned short)0x00B7];
@@ -221,7 +221,7 @@ - (void)updateLineNumbersForClipView:(NSClipView *)clipView checkWidth:(BOOL)che
NSInteger widthOfStringInGutter = [lineNumbersString sizeWithAttributes:self.attributes].width;
if (widthOfStringInGutter > ([[document valueForKey:MGSFOGutterWidth] integerValue] - 14)) { // Check if the gutterTextView has to be resized
- [document setValue:[NSNumber numberWithInteger:widthOfStringInGutter + 20] forKey:MGSFOGutterWidth]; // Make it bigger than need be so it doesn't have to resized soon again
+ [document setValue:@(widthOfStringInGutter + 20) forKey:MGSFOGutterWidth]; // Make it bigger than need be so it doesn't have to resized soon again
if ([[document valueForKey:MGSFOShowLineNumberGutter] boolValue] == YES) {
gutterWidth = [[document valueForKey:MGSFOGutterWidth] integerValue];
} else {
diff --git a/SMLStandardHeader.h b/SMLStandardHeader.h
index d539fc30..1a0d0de5 100644
--- a/SMLStandardHeader.h
+++ b/SMLStandardHeader.h
@@ -29,48 +29,48 @@ Unless required by applicable law or agreed to in writing, software distributed
#endif
-typedef enum {
+typedef NS_ENUM(NSInteger, SMLLineEndings) {
SMLDefaultsLineEndings = 0,
SMLUnixLineEndings = 1,
SMLMacLineEndings = 2,
SMLDarkSideLineEndings = 3,
SMLLeaveLineEndingsUnchanged = 6
-} SMLLineEndings;
+} ;
-typedef enum {
+typedef NS_ENUM(NSInteger, SMLAdvancedFindScope) {
SMLCurrentDocumentScope = 0,
SMLCurrentProjectScope = 1,
SMLAllDocumentsScope = 2
-} SMLAdvancedFindScope;
+} ;
-typedef enum {
+typedef NS_OPTIONS(NSUInteger, SMLView) {
SMLListView = 0
-} SMLView;
+} ;
-typedef enum {
+typedef NS_ENUM(NSInteger, SMLWhatKindOfProject) {
SMLVirtualProject = 0,
SMLPermantProject = 1
-} SMLWhatKindOfProject;
+} ;
-typedef enum {
+typedef NS_ENUM(NSInteger, SMLCheckForUpdatesInterval) {
SMLCheckForUpdatesNever = 0,
SMLCheckForUpdatesDaily = 1,
SMLCheckForUpdatesWeekly = 2,
SMLCheckForUpdatesMonthly = 3
-} SMLCheckForUpdatesInterval;
+} ;
-typedef enum {
+typedef NS_ENUM(NSInteger, SMLPreviewParser) {
SMLPreviewHTML = 0,
SMLPreviewMarkdown = 1,
SMLPreviewMultiMarkdown = 2,
-} SMLPreviewParser;
+} ;
-typedef enum {
+typedef NS_ENUM(NSInteger, SMLOpenSaveMatrix) {
SMLOpenSaveRemember = 0,
SMLOpenSaveCurrent = 1,
SMLOpenSaveAlways = 2
-} SMLOpenSaveMatrix;
+} ;
typedef struct _AppleEventSelectionRange {
short unused1; // 0 (not used)
@@ -81,9 +81,9 @@ typedef struct _AppleEventSelectionRange {
long theDate; // modification date/time
} AppleEventSelectionRange;
-typedef enum {
+typedef NS_ENUM(NSInteger, SMLErrors) {
SmultronSaveErrorEncodingInapplicable = 1,
-} SMLErrors;
+} ;
#define SMULTRON_ERROR_DOMAIN @"org.smultron.Smultron.ErrorDomain"
diff --git a/SMLSyntaxColouring.h b/SMLSyntaxColouring.h
index 829e75cf..fcb58f2c 100644
--- a/SMLSyntaxColouring.h
+++ b/SMLSyntaxColouring.h
@@ -86,10 +86,10 @@ Unless required by applicable law or agreed to in writing, software distributed
}
@property BOOL reactToChanges;
-@property (retain) NSUndoManager *undoManager;
-@property (nonatomic, retain) NSArray* syntaxErrors;
+@property (strong) NSUndoManager *undoManager;
+@property (nonatomic, strong) NSArray* syntaxErrors;
-- (id)initWithDocument:(id)document;
+- (instancetype)initWithDocument:(id)document;
- (void)pageRecolourTextView:(SMLTextView *)textView;
- (void)pageRecolour;
- (void)applySyntaxDefinition;
diff --git a/SMLSyntaxColouring.m b/SMLSyntaxColouring.m
index dee2c2c9..3c9076e5 100644
--- a/SMLSyntaxColouring.m
+++ b/SMLSyntaxColouring.m
@@ -75,31 +75,31 @@ @interface SMLSyntaxColouring()
@property (copy) NSString *functionDefinition;
@property (copy) NSString *removeFromFunction;
-@property (retain) NSString *secondString;
-@property (retain) NSString *firstString;
-@property (retain) NSString *beginCommand;
-@property (retain) NSString *endCommand;
-@property (retain) NSSet *keywords;
-@property (retain) NSSet *autocompleteWords;
-@property (retain) NSArray *keywordsAndAutocompleteWords;
-@property (retain) NSString *beginInstruction;
-@property (retain) NSString *endInstruction;
-@property (retain) NSCharacterSet *beginVariableCharacterSet;
-@property (retain) NSCharacterSet *endVariableCharacterSet;
-@property (retain) NSString *firstSingleLineComment;
-@property (retain) NSString *secondSingleLineComment;
-@property (retain) NSMutableArray *singleLineComments;
-@property (retain) NSMutableArray *multiLineComments;
-@property (retain) NSString *beginFirstMultiLineComment;
-@property (retain) NSString*endFirstMultiLineComment;
-@property (retain) NSString*beginSecondMultiLineComment;
-@property (retain) NSString*endSecondMultiLineComment;
-@property (retain) NSCharacterSet *keywordStartCharacterSet;
-@property (retain) NSCharacterSet *keywordEndCharacterSet;
-@property (retain) NSCharacterSet *attributesCharacterSet;
-@property (retain) NSCharacterSet *letterCharacterSet;
-@property (retain) NSCharacterSet *numberCharacterSet;
-@property (retain) NSCharacterSet *nameCharacterSet;
+@property (strong) NSString *secondString;
+@property (strong) NSString *firstString;
+@property (strong) NSString *beginCommand;
+@property (strong) NSString *endCommand;
+@property (strong) NSSet *keywords;
+@property (strong) NSSet *autocompleteWords;
+@property (strong) NSArray *keywordsAndAutocompleteWords;
+@property (strong) NSString *beginInstruction;
+@property (strong) NSString *endInstruction;
+@property (strong) NSCharacterSet *beginVariableCharacterSet;
+@property (strong) NSCharacterSet *endVariableCharacterSet;
+@property (strong) NSString *firstSingleLineComment;
+@property (strong) NSString *secondSingleLineComment;
+@property (strong) NSMutableArray *singleLineComments;
+@property (strong) NSMutableArray *multiLineComments;
+@property (strong) NSString *beginFirstMultiLineComment;
+@property (strong) NSString*endFirstMultiLineComment;
+@property (strong) NSString*beginSecondMultiLineComment;
+@property (strong) NSString*endSecondMultiLineComment;
+@property (strong) NSCharacterSet *keywordStartCharacterSet;
+@property (strong) NSCharacterSet *keywordEndCharacterSet;
+@property (strong) NSCharacterSet *attributesCharacterSet;
+@property (strong) NSCharacterSet *letterCharacterSet;
+@property (strong) NSCharacterSet *numberCharacterSet;
+@property (strong) NSCharacterSet *nameCharacterSet;
@property (assign) BOOL syntaxDefinitionAllowsColouring;
@property unichar decimalPointCharacter;
@@ -154,9 +154,9 @@ - (id)initWithDocument:(id)theDocument
NSAssert(theDocument, @"bad document");
// retain the document
- document = [theDocument retain];
+ document = theDocument;
- self.undoManager = [[[NSUndoManager alloc] init] autorelease];
+ self.undoManager = [[NSUndoManager alloc] init];
// configure the document text view
NSTextView *textView = [document valueForKey:ro_MGSFOTextView];
@@ -179,31 +179,31 @@ - (id)initWithDocument:(id)theDocument
self.letterCharacterSet = [NSCharacterSet letterCharacterSet];
// name character set
- NSMutableCharacterSet *temporaryCharacterSet = [[[NSCharacterSet letterCharacterSet] mutableCopy] autorelease];
+ NSMutableCharacterSet *temporaryCharacterSet = [[NSCharacterSet letterCharacterSet] mutableCopy];
[temporaryCharacterSet addCharactersInString:@"_"];
- self.nameCharacterSet = [[temporaryCharacterSet copy] autorelease];
+ self.nameCharacterSet = [temporaryCharacterSet copy];
// keyword start character set
- temporaryCharacterSet = [[[NSCharacterSet letterCharacterSet] mutableCopy] autorelease];
+ temporaryCharacterSet = [[NSCharacterSet letterCharacterSet] mutableCopy];
[temporaryCharacterSet addCharactersInString:@"_:@#"];
- self.keywordStartCharacterSet = [[temporaryCharacterSet copy] autorelease];
+ self.keywordStartCharacterSet = [temporaryCharacterSet copy];
// keyword end character set
// see http://www.fileformat.info/info/unicode/category/index.htm for categories that make up the sets
- temporaryCharacterSet = [[[NSCharacterSet whitespaceAndNewlineCharacterSet] mutableCopy] autorelease];
+ temporaryCharacterSet = [[NSCharacterSet whitespaceAndNewlineCharacterSet] mutableCopy];
[temporaryCharacterSet formUnionWithCharacterSet:[NSCharacterSet symbolCharacterSet]];
[temporaryCharacterSet formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]];
[temporaryCharacterSet removeCharactersInString:@"_-"]; // common separators in variable names
- self.keywordEndCharacterSet = [[temporaryCharacterSet copy] autorelease];
+ self.keywordEndCharacterSet = [temporaryCharacterSet copy];
// number character set
self.numberCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789."];
self.decimalPointCharacter = [@"." characterAtIndex:0];
// attributes character set
- temporaryCharacterSet = [[[NSCharacterSet alphanumericCharacterSet] mutableCopy] autorelease];
+ temporaryCharacterSet = [[NSCharacterSet alphanumericCharacterSet] mutableCopy];
[temporaryCharacterSet addCharactersInString:@" -"]; // If there are two spaces before an attribute
- self.attributesCharacterSet = [[temporaryCharacterSet copy] autorelease];
+ self.attributesCharacterSet = [temporaryCharacterSet copy];
// configure syntax definition
[self applySyntaxDefinition];
@@ -255,10 +255,6 @@ - (id)initWithDocument:(id)theDocument
- dealloc
*/
-- (void) dealloc {
- [document release];
- [super dealloc];
-}
#pragma mark -
#pragma mark KVO
/*
@@ -268,7 +264,7 @@ - (void) dealloc {
*/
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
- if ([(NSString *)context isEqualToString:@"ColoursChanged"]) {
+ if ([(__bridge NSString *)context isEqualToString:@"ColoursChanged"]) {
[self applyColourDefaults];
[self pageRecolour];
if ([[SMLDefaults valueForKey:MGSFragariaPrefsHighlightCurrentLine] boolValue] == YES) {
@@ -278,10 +274,10 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
} else {
[self highlightLineRange:NSMakeRange(0, 0)];
}
- } else if ([(NSString *)context isEqualToString:@"MultiLineChanged"]) {
+ } else if ([(__bridge NSString *)context isEqualToString:@"MultiLineChanged"]) {
[self prepareRegularExpressions];
[self pageRecolour];
- } else if ([(NSString *)context isEqualToString:@"syntaxDefinition"]) {
+ } else if ([(__bridge NSString *)context isEqualToString:@"syntaxDefinition"]) {
[self applySyntaxDefinition];
[self removeAllColours];
[self pageRecolour];
@@ -391,7 +387,7 @@ - (void)parseSyntaxDictionary:(NSDictionary *)syntaxDictionary
value = [syntaxDictionary valueForKey:SMLSyntaxDefinitionKeywords];
if (value) {
NSAssert([value isKindOfClass:[NSArray class]], @"NSArray expected");
- self.keywords = [[[NSSet alloc] initWithArray:value] autorelease];
+ self.keywords = [[NSSet alloc] initWithArray:value];
[keywordsAndAutocompleteWordsTemporary addObjectsFromArray:value];
}
@@ -399,7 +395,7 @@ - (void)parseSyntaxDictionary:(NSDictionary *)syntaxDictionary
value = [syntaxDictionary valueForKey:SMLSyntaxDefinitionAutocompleteWords];
if (value) {
NSAssert([value isKindOfClass:[NSArray class]], @"NSArray expected");
- self.autocompleteWords = [[[NSSet alloc] initWithArray:value] autorelease];
+ self.autocompleteWords = [[NSSet alloc] initWithArray:value];
[keywordsAndAutocompleteWordsTemporary addObjectsFromArray:value];
}
@@ -426,12 +422,12 @@ - (void)parseSyntaxDictionary:(NSDictionary *)syntaxDictionary
}
if (keywordsCaseSensitive == NO) {
- NSMutableArray *lowerCaseKeywords = [[[NSMutableArray alloc] init] autorelease];
+ NSMutableArray *lowerCaseKeywords = [[NSMutableArray alloc] init];
for (id item in keywords) {
[lowerCaseKeywords addObject:[item lowercaseString]];
}
- NSSet *lowerCaseKeywordsSet = [[[NSSet alloc] initWithArray:lowerCaseKeywords] autorelease];
+ NSSet *lowerCaseKeywordsSet = [[NSSet alloc] initWithArray:lowerCaseKeywords];
self.keywords = lowerCaseKeywordsSet;
}
@@ -554,7 +550,7 @@ - (void)parseSyntaxDictionary:(NSDictionary *)syntaxDictionary
}
self.multiLineComments = [NSMutableArray arrayWithCapacity:2];
- [self.multiLineComments addObject:[NSArray arrayWithObjects:self.beginFirstMultiLineComment, self.endFirstMultiLineComment, nil]];
+ [self.multiLineComments addObject:@[self.beginFirstMultiLineComment, self.endFirstMultiLineComment]];
// begin second multi line comment
value = [syntaxDictionary valueForKey:SMLSyntaxDefinitionBeginSecondMultiLineComment];
@@ -573,7 +569,7 @@ - (void)parseSyntaxDictionary:(NSDictionary *)syntaxDictionary
} else {
self.endSecondMultiLineComment = @"";
}
- [self.multiLineComments addObject:[NSArray arrayWithObjects:self.beginSecondMultiLineComment, self.endSecondMultiLineComment, nil]];
+ [self.multiLineComments addObject:@[self.beginSecondMultiLineComment, self.endSecondMultiLineComment]];
// function definition
value = [syntaxDictionary valueForKey:SMLSyntaxDefinitionFunctionDefinition];
@@ -597,36 +593,36 @@ - (void)parseSyntaxDictionary:(NSDictionary *)syntaxDictionary
value = [syntaxDictionary valueForKey:SMLSyntaxDefinitionExcludeFromKeywordStartCharacterSet];
if (value) {
NSAssert([value isKindOfClass:[NSString class]], @"NSString expected");
- NSMutableCharacterSet *temporaryCharacterSet = [[keywordStartCharacterSet mutableCopy] autorelease];
+ NSMutableCharacterSet *temporaryCharacterSet = [keywordStartCharacterSet mutableCopy];
[temporaryCharacterSet removeCharactersInString:value];
- self.keywordStartCharacterSet = [[temporaryCharacterSet copy] autorelease];
+ self.keywordStartCharacterSet = [temporaryCharacterSet copy];
}
// exclude characters from keyword end character set
value = [syntaxDictionary valueForKey:SMLSyntaxDefinitionExcludeFromKeywordEndCharacterSet];
if (value) {
NSAssert([value isKindOfClass:[NSString class]], @"NSString expected");
- NSMutableCharacterSet *temporaryCharacterSet = [[keywordEndCharacterSet mutableCopy] autorelease];
+ NSMutableCharacterSet *temporaryCharacterSet = [keywordEndCharacterSet mutableCopy];
[temporaryCharacterSet removeCharactersInString:value];
- self.keywordEndCharacterSet = [[temporaryCharacterSet copy] autorelease];
+ self.keywordEndCharacterSet = [temporaryCharacterSet copy];
}
// include characters in keyword start character set
value = [syntaxDictionary valueForKey:SMLSyntaxDefinitionIncludeInKeywordStartCharacterSet];
if (value) {
NSAssert([value isKindOfClass:[NSString class]], @"NSString expected");
- NSMutableCharacterSet *temporaryCharacterSet = [[keywordStartCharacterSet mutableCopy] autorelease];
+ NSMutableCharacterSet *temporaryCharacterSet = [keywordStartCharacterSet mutableCopy];
[temporaryCharacterSet addCharactersInString:value];
- self.keywordStartCharacterSet = [[temporaryCharacterSet copy] autorelease];
+ self.keywordStartCharacterSet = [temporaryCharacterSet copy];
}
// include characters in keyword end character set
value = [syntaxDictionary valueForKey:SMLSyntaxDefinitionIncludeInKeywordEndCharacterSet];
if (value) {
NSAssert([value isKindOfClass:[NSString class]], @"NSString expected");
- NSMutableCharacterSet *temporaryCharacterSet = [[keywordEndCharacterSet mutableCopy] autorelease];
+ NSMutableCharacterSet *temporaryCharacterSet = [keywordEndCharacterSet mutableCopy];
[temporaryCharacterSet addCharactersInString:value];
- self.keywordEndCharacterSet = [[temporaryCharacterSet copy] autorelease];
+ self.keywordEndCharacterSet = [temporaryCharacterSet copy];
}
[self prepareRegularExpressions];
@@ -774,7 +770,7 @@ - (void)pageRecolourTextView:(SMLTextView *)textView options:(NSDictionary *)opt
}
// colourAll option
- NSNumber *colourAll = [options objectForKey:@"colourAll"];
+ NSNumber *colourAll = options[@"colourAll"];
if (!colourAll || ![colourAll boolValue]) {
[self pageRecolourTextView:textView];
return;
@@ -842,11 +838,11 @@ - (void)recolourRange:(NSRange)rangeToRecolour
}
// allocate the range scanner
- NSScanner *rangeScanner = [[[NSScanner alloc] initWithString:rangeString] autorelease];
+ NSScanner *rangeScanner = [[NSScanner alloc] initWithString:rangeString];
[rangeScanner setCharactersToBeSkipped:nil];
// allocate the document scanner
- NSScanner *documentScanner = [[[NSScanner alloc] initWithString:documentString] autorelease];
+ NSScanner *documentScanner = [[NSScanner alloc] initWithString:documentString];
[documentScanner setCharactersToBeSkipped:nil];
// uncolour the range
@@ -1503,8 +1499,8 @@ - (void)recolourRange:(NSRange)rangeToRecolour
for (NSArray *multiLineComment in self.multiLineComments) {
// Get strings
- NSString *beginMultiLineComment = [multiLineComment objectAtIndex:0];
- NSString *endMultiLineComment = [multiLineComment objectAtIndex:1];
+ NSString *beginMultiLineComment = multiLineComment[0];
+ NSString *endMultiLineComment = multiLineComment[1];
if (![beginMultiLineComment isEqualToString:@""]) {
@@ -1697,25 +1693,25 @@ - (void)setColour:(NSDictionary *)colourDictionary range:(NSRange)range
*/
- (void)applyColourDefaults
{
- commandsColour = [[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsCommandsColourWell]], NSForegroundColorAttributeName, nil];
+ commandsColour = @{NSForegroundColorAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsCommandsColourWell]]};
- commentsColour = [[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsCommentsColourWell]], NSForegroundColorAttributeName, nil];
+ commentsColour = @{NSForegroundColorAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsCommentsColourWell]]};
- instructionsColour = [[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsInstructionsColourWell]], NSForegroundColorAttributeName, nil];
+ instructionsColour = @{NSForegroundColorAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsInstructionsColourWell]]};
- keywordsColour = [[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsKeywordsColourWell]], NSForegroundColorAttributeName, nil];
+ keywordsColour = @{NSForegroundColorAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsKeywordsColourWell]]};
- autocompleteWordsColour = [[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsAutocompleteColourWell]], NSForegroundColorAttributeName, nil];
+ autocompleteWordsColour = @{NSForegroundColorAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsAutocompleteColourWell]]};
- stringsColour = [[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsStringsColourWell]], NSForegroundColorAttributeName, nil];
+ stringsColour = @{NSForegroundColorAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsStringsColourWell]]};
- variablesColour = [[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsVariablesColourWell]], NSForegroundColorAttributeName, nil];
+ variablesColour = @{NSForegroundColorAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsVariablesColourWell]]};
- attributesColour = [[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsAttributesColourWell]], NSForegroundColorAttributeName, nil];
+ attributesColour = @{NSForegroundColorAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsAttributesColourWell]]};
- lineHighlightColour = [[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsHighlightLineColourWell]], NSBackgroundColorAttributeName, nil];
+ lineHighlightColour = @{NSBackgroundColorAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsHighlightLineColourWell]]};
- numbersColour = [[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsNumbersColourWell]], NSForegroundColorAttributeName, nil];
+ numbersColour = @{NSForegroundColorAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsNumbersColourWell]]};
}
@@ -1825,10 +1821,10 @@ - (void) highlightErrors
NSRange lineRange = [text lineRangeForRange:NSMakeRange(location, 0)];
// Highlight row if it is not already highlighted
- if (![highlightedRows containsObject:[NSNumber numberWithInt:err.line]])
+ if (![highlightedRows containsObject:@(err.line)])
{
// Remember that we are highlighting this row
- [highlightedRows addObject:[NSNumber numberWithInt:err.line]];
+ [highlightedRows addObject:@(err.line)];
// Add highlight for background
[firstLayoutManager addTemporaryAttribute:NSBackgroundColorAttributeName value:[NSColor colorWithCalibratedRed:1 green:1 blue:0.7 alpha:1] forCharacterRange:lineRange];
@@ -1842,13 +1838,13 @@ - (void) highlightErrors
// Add button
float scrollOffset = textView.superview.bounds.origin.x - 0;
- NSButton* warningButton = [[[NSButton alloc] initWithFrame:NSMakeRect(textView.superview.frame.size.width - 32 + scrollOffset, linePos.origin.y-2, 16, 16)] autorelease];
+ NSButton* warningButton = [[NSButton alloc] initWithFrame:NSMakeRect(textView.superview.frame.size.width - 32 + scrollOffset, linePos.origin.y-2, 16, 16)];
[warningButton setButtonType:NSMomentaryChangeButton];
[warningButton setBezelStyle:NSRegularSquareBezelStyle];
[warningButton setBordered:NO];
[warningButton setImagePosition:NSImageOnly];
- [warningButton setImage:[MGSFragaria imageNamed:@"editor-warning.png"]];
+ [warningButton setImage:[MGSFragaria imageNamed:@"editor-warning"]];
[warningButton setTag:err.line];
[warningButton setTarget:self];
[warningButton setAction:@selector(pressedWarningBtn:)];
@@ -1864,8 +1860,8 @@ - (void) highlightErrors
*/
- (CGFloat) widthOfString:(NSString *)string withFont:(NSFont *)font {
- NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil];
- return [[[[NSAttributedString alloc] initWithString:string attributes:attributes] autorelease] size].width;
+ NSDictionary *attributes = @{NSFontAttributeName: font};
+ return [[[NSAttributedString alloc] initWithString:string attributes:attributes] size].width;
}
#pragma mark -
@@ -1907,7 +1903,10 @@ - (void)performDocumentDelegateSelector:(SEL)selector withObject:(id)object
{
id delegate = [document valueForKey:MGSFODelegate];
if (delegate && [delegate respondsToSelector:selector]) {
- [delegate performSelector:selector withObject:object];
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
+ [delegate performSelector:selector withObject:object];
+#pragma clang diagnostic pop
}
}
@@ -1937,7 +1936,7 @@ - (void)textDidChange:(NSNotification *)notification
SMLTextView *textView = (SMLTextView *)[notification object];
if ([[document valueForKey:MGSFOIsEdited] boolValue] == NO) {
- [document setValue:[NSNumber numberWithBool:YES] forKey:MGSFOIsEdited];
+ [document setValue:@YES forKey:MGSFOIsEdited];
}
if ([[SMLDefaults valueForKey:MGSFragariaPrefsHighlightCurrentLine] boolValue] == YES) {
@@ -2185,7 +2184,7 @@ - (void)undoManagerDidUndo:(NSNotification *)aNote
if (![theUndoManager canUndo]) {
// we can undo no more so we must be restored to unedited state
- [document setValue:[NSNumber numberWithBool:NO] forKey:MGSFOIsEdited];
+ [document setValue:@NO forKey:MGSFOIsEdited];
//should data be reloaded?
}
diff --git a/SMLSyntaxColouringDelegate.h b/SMLSyntaxColouringDelegate.h
index d1921c7e..e1305482 100644
--- a/SMLSyntaxColouringDelegate.h
+++ b/SMLSyntaxColouringDelegate.h
@@ -30,7 +30,7 @@ extern NSString *SMLSyntaxGroupMultiLineComment;
extern NSString *SMLSyntaxGroupSecondStringPass2;
// syntax colouring group IDs
-enum {
+typedef NS_ENUM(NSInteger, SMLSyntaxGroupInteger) {
kSMLSyntaxGroupNumber = 0,
kSMLSyntaxGroupCommand = 1,
kSMLSyntaxGroupInstruction = 2,
@@ -44,7 +44,6 @@ enum {
kSMLSyntaxGroupMultiLineComment = 10,
kSMLSyntaxGroupSecondStringPass2 = 11
};
-typedef NSInteger SMLSyntaxGroupInteger;
@protocol SMLSyntaxColouringDelegate
diff --git a/SMLSyntaxError.m b/SMLSyntaxError.m
index bb3aa0ee..a511f2c2 100644
--- a/SMLSyntaxError.m
+++ b/SMLSyntaxError.m
@@ -12,11 +12,5 @@ @implementation SMLSyntaxError
@synthesize line, character, code, length, description;
-- (void) dealloc
-{
- self.description = NULL;
- self.code = NULL;
- [super dealloc];
-}
@end
diff --git a/SMLTextPerformer.m b/SMLTextPerformer.m
index 35a670f7..9a395317 100644
--- a/SMLTextPerformer.m
+++ b/SMLTextPerformer.m
@@ -112,12 +112,12 @@ - (NSString *)convertLineEndings:(NSString *)stringToConvert inDocument:(id)docu
*/
- (NSStringEncoding)guessEncodingFromData:(NSData *)textData
{
- NSString *string = [[[NSString alloc] initWithData:textData encoding:NSISOLatin1StringEncoding] autorelease];
+ NSString *string = [[NSString alloc] initWithData:textData encoding:NSISOLatin1StringEncoding];
NSStringEncoding encoding = 0;
BOOL foundExplicitEncoding = NO;
if ([string length] > 9) { // If it's shorter than this you can't check for encoding string
- NSScanner *scannerHTML = [[[NSScanner alloc] initWithString:string] autorelease];
+ NSScanner *scannerHTML = [[NSScanner alloc] initWithString:string];
NSUInteger beginning;
NSInteger end;
@@ -134,7 +134,7 @@ - (NSStringEncoding)guessEncodingFromData:(NSData *)textData
encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)[string substringWithRange:NSMakeRange(beginning, end - beginning)]));
foundExplicitEncoding = YES;
} else {
- NSScanner *scannerXML = [[[NSScanner alloc] initWithString:string] autorelease];
+ NSScanner *scannerXML = [[NSScanner alloc] initWithString:string];
[scannerXML scanUpToString:@"encoding=" intoString:nil]; // If not found, search for "encoding=" (xml) and get the string after that
if ([scannerXML scanLocation] < [string length] - 9) {
beginning = [scannerXML scanLocation] + 9 + 1; // After the " or '
diff --git a/SMLTextView.h b/SMLTextView.h
index 06217f9e..d59d9c7c 100644
--- a/SMLTextView.h
+++ b/SMLTextView.h
@@ -37,15 +37,15 @@ Unless required by applicable law or agreed to in writing, software distributed
BOOL lineWrap;
}
-@property (retain) NSCursor *colouredIBeamCursor;
-@property (retain) MGSFragaria *fragaria;
+@property (strong) NSCursor *colouredIBeamCursor;
+@property (strong) MGSFragaria *fragaria;
@property (nonatomic) BOOL lineWrap;
- (void)setDefaults;
- (void)setTextDefaults;
-- (NSInteger)lineHeight;
+@property (NS_NONATOMIC_IOSONLY, readonly) NSInteger lineHeight;
- (void)setTabWidth;
diff --git a/SMLTextView.m b/SMLTextView.m
index 84f3353e..6b71b279 100644
--- a/SMLTextView.m
+++ b/SMLTextView.m
@@ -26,7 +26,7 @@
@interface SMLTextView()
- (void)windowDidBecomeMainOrKey:(NSNotification *)note;
-@property (retain) NSColor *pageGuideColour;
+@property (strong) NSColor *pageGuideColour;
@end
@@ -41,10 +41,10 @@ @implementation SMLTextView
- initWithFrame:
*/
-- (id)initWithFrame:(NSRect)frame
+- (instancetype)initWithFrame:(NSRect)frame
{
if ((self = [super initWithFrame:frame])) {
- SMLLayoutManager *layoutManager = [[[SMLLayoutManager alloc] init] autorelease];
+ SMLLayoutManager *layoutManager = [[SMLLayoutManager alloc] init];
[[self textContainer] replaceLayoutManager:layoutManager];
[self setDefaults];
@@ -112,7 +112,6 @@ - (void)setDefaults
[self updateIBeamCursor];
NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:[self frame] options:(NSTrackingMouseEnteredAndExited | NSTrackingActiveWhenFirstResponder) owner:self userInfo:nil];
[self addTrackingArea:trackingArea];
- [trackingArea autorelease];
NSUserDefaultsController *defaultsController = [NSUserDefaultsController sharedUserDefaultsController];
[defaultsController addObserver:self forKeyPath:@"values.FragariaTextFont" options:NSKeyValueObservingOptionNew context:@"TextFontChanged"];
@@ -188,23 +187,23 @@ -(void)paste:(id)sender
*/
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
- if ([(NSString *)context isEqualToString:@"TextFontChanged"]) {
+ if ([(__bridge NSString *)context isEqualToString:@"TextFontChanged"]) {
[self setFont:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextFont]]];
lineHeight = [[[self textContainer] layoutManager] defaultLineHeightForFont:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextFont]]];
[[fragaria objectForKey:ro_MGSFOLineNumbers] updateLineNumbersForClipView:[[self enclosingScrollView] contentView] checkWidth:NO recolour:YES];
[self setPageGuideValues];
- } else if ([(NSString *)context isEqualToString:@"TextColourChanged"]) {
+ } else if ([(__bridge NSString *)context isEqualToString:@"TextColourChanged"]) {
[self setTextColor:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextColourWell]]];
[self setInsertionPointColor:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextColourWell]]];
[self setPageGuideValues];
[self updateIBeamCursor];
- } else if ([(NSString *)context isEqualToString:@"BackgroundColourChanged"]) {
+ } else if ([(__bridge NSString *)context isEqualToString:@"BackgroundColourChanged"]) {
[self setBackgroundColor:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsBackgroundColourWell]]];
- } else if ([(NSString *)context isEqualToString:@"SmartInsertDeleteChanged"]) {
+ } else if ([(__bridge NSString *)context isEqualToString:@"SmartInsertDeleteChanged"]) {
[self setSmartInsertDeleteEnabled:[[SMLDefaults valueForKey:MGSFragariaPrefsSmartInsertDelete] boolValue]];
- } else if ([(NSString *)context isEqualToString:@"TabWidthChanged"]) {
+ } else if ([(__bridge NSString *)context isEqualToString:@"TabWidthChanged"]) {
[self setTabWidth];
- } else if ([(NSString *)context isEqualToString:@"PageGuideChanged"]) {
+ } else if ([(__bridge NSString *)context isEqualToString:@"PageGuideChanged"]) {
[self setPageGuideValues];
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
@@ -416,17 +415,17 @@ - (void)setTabWidth
while (numberOfSpaces--) {
[sizeString appendString:@" "];
}
- NSDictionary *sizeAttribute = [[[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextFont]], NSFontAttributeName, nil] autorelease];
+ NSDictionary *sizeAttribute = @{NSFontAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextFont]]};
CGFloat sizeOfTab = [sizeString sizeWithAttributes:sizeAttribute].width;
- NSMutableParagraphStyle *style = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
+ NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
NSArray *array = [style tabStops];
for (id item in array) {
[style removeTabStop:item];
}
[style setDefaultTabInterval:sizeOfTab];
- NSDictionary *attributes = [[[NSDictionary alloc] initWithObjectsAndKeys:style, NSParagraphStyleAttributeName, nil] autorelease];
+ NSDictionary *attributes = @{NSParagraphStyleAttributeName: style};
[self setTypingAttributes:attributes];
}
@@ -437,7 +436,7 @@ - (void)setTabWidth
*/
- (void)setPageGuideValues
{
- NSDictionary *sizeAttribute = [[[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextFont]], NSFontAttributeName, nil] autorelease];
+ NSDictionary *sizeAttribute = @{NSFontAttributeName: [NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextFont]]};
NSString *sizeString = @" ";
CGFloat sizeOfCharacter = [sizeString sizeWithAttributes:sizeAttribute].width;
pageGuideX = (sizeOfCharacter * ([[SMLDefaults valueForKey:MGSFragariaPrefsShowPageGuideAtColumn] integerValue] + 1)) - 1.5f; // -1.5 to put it between the two characters and draw only on one pixel and not two (as the system draws it in a special way), and that's also why the width above is set to zero
@@ -482,7 +481,7 @@ - (void)insertText:(NSString *)aString
if (characterToCheck == '{') {
if (skipMatchingBrace == 0) { // If we have found the opening brace check first how much space is in front of that line so the same amount can be inserted in front of the new line
NSString *openingBraceLineWhitespaceString;
- NSScanner *openingLineScanner = [[[NSScanner alloc] initWithString:[completeString substringWithRange:[completeString lineRangeForRange:NSMakeRange(location, 0)]]] autorelease];
+ NSScanner *openingLineScanner = [[NSScanner alloc] initWithString:[completeString substringWithRange:[completeString lineRangeForRange:NSMakeRange(location, 0)]]];
[openingLineScanner setCharactersToBeSkipped:nil];
BOOL foundOpeningBraceWhitespace = [openingLineScanner scanCharactersFromSet:whitespaceCharacterSet intoString:&openingBraceLineWhitespaceString];
@@ -561,7 +560,7 @@ - (void)insertNewline:(id)sender
NSString *lastLineString = [[self string] substringWithRange:[[self string] lineRangeForRange:NSMakeRange([self selectedRange].location - 1, 0)]];
if ([[SMLDefaults valueForKey:MGSFragariaPrefsIndentNewLinesAutomatically] boolValue] == YES) {
NSString *previousLineWhitespaceString;
- NSScanner *previousLineScanner = [[[NSScanner alloc] initWithString:[[self string] substringWithRange:[[self string] lineRangeForRange:NSMakeRange([self selectedRange].location - 1, 0)]]] autorelease];
+ NSScanner *previousLineScanner = [[NSScanner alloc] initWithString:[[self string] substringWithRange:[[self string] lineRangeForRange:NSMakeRange([self selectedRange].location - 1, 0)]]];
[previousLineScanner setCharactersToBeSkipped:nil];
if ([previousLineScanner scanCharactersFromSet:[NSCharacterSet whitespaceCharacterSet] intoString:&previousLineWhitespaceString]) {
[self insertText:previousLineWhitespaceString];
@@ -611,7 +610,7 @@ - (void)setString:(NSString *)text options:(NSDictionary *)options
*/
- (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)text options:(NSDictionary *)options
{
- BOOL undo = [[options objectForKey:@"undo"] boolValue];
+ BOOL undo = [options[@"undo"] boolValue];
BOOL textViewWasEmpty = ([self.textStorage length] == 0 ? YES : NO);
if ([self isEditable] && undo) {
@@ -664,7 +663,7 @@ - (void)setAttributedString:(NSAttributedString *)text
*/
- (void)setAttributedString:(NSAttributedString *)text options:(NSDictionary *)options
{
- BOOL undo = [[options objectForKey:@"undo"] boolValue];
+ BOOL undo = [options[@"undo"] boolValue];
NSTextStorage *textStorage = [self textStorage];
@@ -945,7 +944,7 @@ - (void)updateIBeamCursor
[(NSColor *)[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:MGSFragariaPrefsTextColourWell]] set];
NSRectFillUsingOperation(NSMakeRect(0, 0, [cursorImage size].width, [cursorImage size].height), NSCompositeSourceAtop);
[cursorImage unlockFocus];
- NSCursor *cursor = [[[NSCursor alloc] initWithImage:cursorImage hotSpot:[[NSCursor IBeamCursor] hotSpot]] autorelease];
+ NSCursor *cursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[NSCursor IBeamCursor] hotSpot]];
[self setColouredIBeamCursor:cursor];
}
}