Added Helper Categories
Added Documentation
This commit is contained in:
21
MathPad/NSIndexPath+MPRemoveFirstIndex.h
Normal file
21
MathPad/NSIndexPath+MPRemoveFirstIndex.h
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// NSIndexPath+MPRemoveFirstIndex.h
|
||||
// MathPad
|
||||
//
|
||||
// Created by Kim Wittenburg on 23.04.14.
|
||||
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSIndexPath (MPRemoveFirstIndex)
|
||||
|
||||
/*!
|
||||
@method indexPathByRemovingFirstIndex
|
||||
@brief Provides an index path with the indexes in the receiving index path, excluding the first one.
|
||||
@discussion Returns an empty NSIndexPath instance if the receiving index path’s length is 1 or less.
|
||||
@return New index path with the receiving index path’s indexes, excluding the first one.
|
||||
*/
|
||||
- (NSIndexPath *)indexPathByRemovingFirstIndex;
|
||||
|
||||
@end
|
||||
27
MathPad/NSIndexPath+MPRemoveFirstIndex.m
Normal file
27
MathPad/NSIndexPath+MPRemoveFirstIndex.m
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// NSIndexPath+MPRemoveFirstIndex.m
|
||||
// MathPad
|
||||
//
|
||||
// Created by Kim Wittenburg on 23.04.14.
|
||||
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSIndexPath+MPRemoveFirstIndex.h"
|
||||
|
||||
@implementation NSIndexPath (MPRemoveFirstIndex)
|
||||
|
||||
- (NSIndexPath *)indexPathByRemovingFirstIndex
|
||||
{
|
||||
if (self.length <= 1) {
|
||||
return [[NSIndexPath alloc] init];
|
||||
}
|
||||
NSUInteger indexes[self.length];
|
||||
[self getIndexes:indexes];
|
||||
NSUInteger newIndexes[self.length-1];
|
||||
for (NSUInteger i = 0; i < self.length-1; i++) {
|
||||
newIndexes[i] = indexes[i+1];
|
||||
}
|
||||
return [[NSIndexPath alloc] initWithIndexes:newIndexes length:self.length-1];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
@interface NSObject (MPStringTest)
|
||||
|
||||
/*!
|
||||
@method isString
|
||||
@brief Returns wether the receiver is a string object.
|
||||
@discussion A string object is an instance of the @c NSString class or any of its subclasses (for example @c NSMutableString). For an @c NSAttributedString this method returns @c NO.
|
||||
@return @c YES if the receiver is an instance of @c NSString or a subclass, @c NO otherwise.
|
||||
*/
|
||||
- (BOOL)isString;
|
||||
|
||||
@end
|
||||
|
||||
21
MathPad/NSTextStorage+MPSetContents.h
Normal file
21
MathPad/NSTextStorage+MPSetContents.h
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// NSTextStorage+MPSetContents.h
|
||||
// MathPad
|
||||
//
|
||||
// Created by Kim Wittenburg on 21.04.14.
|
||||
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface NSTextStorage (MPSetContents)
|
||||
|
||||
/*!
|
||||
@method setString:
|
||||
@brief Replaces the contents of the receiver with @c aString.
|
||||
@discussion This method sends the receiver a @c replaceCharactersInRange:withString: with a range including all characters of the receiver and @c aString. See @c replaceCharactersInRange:withString: for details.
|
||||
@param aString A string specifying the characters to replace the receiver's current contents.
|
||||
*/
|
||||
- (void)setString:(NSString *)aString;
|
||||
|
||||
@end
|
||||
19
MathPad/NSTextStorage+MPSetContents.m
Normal file
19
MathPad/NSTextStorage+MPSetContents.m
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// NSTextStorage+MPSetContents.m
|
||||
// MathPad
|
||||
//
|
||||
// Created by Kim Wittenburg on 21.04.14.
|
||||
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSTextStorage+MPSetContents.h"
|
||||
|
||||
@implementation NSTextStorage (MPSetContents)
|
||||
|
||||
- (void)setString:(NSString *)string
|
||||
{
|
||||
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:string];
|
||||
[self setAttributedString:attributedString];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user