Skip to content

Commit

Permalink
Merge pull request objcio#2 from macguru/master
Browse files Browse the repository at this point in the history
A few minor changes to bring the code up to date with the article.
  • Loading branch information
Florian Kugler committed Oct 12, 2013
2 parents 688b6ac + 4f0600b commit 5ebb2cd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions TextKitDemo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4510" systemVersion="13A584" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="8YX-ce-x5E">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4510" systemVersion="12F37" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="8YX-ce-x5E">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3742"/>
</dependencies>
Expand Down Expand Up @@ -59,9 +59,9 @@
</barButtonItem>
</navigationItem>
<connections>
<outlet property="firstContainerView" destination="ZV7-VL-Kd8" id="j7g-8S-IGf"/>
<outlet property="secondContainerView" destination="auf-0B-h3H" id="tBy-kC-6fx"/>
<outlet property="singleTextView" destination="JYe-Ji-kZb" id="H38-cm-duT"/>
<outlet property="originalTextView" destination="JYe-Ji-kZb" id="azn-Os-b6F"/>
<outlet property="otherContainerView" destination="ZV7-VL-Kd8" id="rhr-Lz-U9r"/>
<outlet property="thirdContainerView" destination="auf-0B-h3H" id="dEJ-jx-kgm"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ceL-7Y-pUS" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
6 changes: 3 additions & 3 deletions TextKitDemo/Configuration/TKDConfigurationViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

@interface TKDConfigurationViewController : UIViewController

@property (weak, nonatomic) IBOutlet UITextView *singleTextView;
@property (weak, nonatomic) IBOutlet UITextView *originalTextView;

@property (weak, nonatomic) IBOutlet UIView *firstContainerView;
@property (weak, nonatomic) IBOutlet UIView *secondContainerView;
@property (weak, nonatomic) IBOutlet UIView *otherContainerView;
@property (weak, nonatomic) IBOutlet UIView *thirdContainerView;

- (IBAction)endEditing:(UIBarButtonItem *)sender;

Expand Down
46 changes: 23 additions & 23 deletions TextKitDemo/Configuration/TKDConfigurationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

@interface TKDConfigurationViewController ()

@property (weak, nonatomic) UITextView *firstTextView;
@property (weak, nonatomic) UITextView *secondTextView;
@property (weak, nonatomic) UITextView *otherTextView;
@property (weak, nonatomic) UITextView *thirdTextView;

@end

Expand All @@ -22,39 +22,39 @@ - (void)viewDidLoad
[super viewDidLoad];

// Load text
NSTextStorage *upperTextStorage = self.singleTextView.textStorage;
[upperTextStorage replaceCharactersInRange:NSMakeRange(0, 0) withString:[NSString stringWithContentsOfURL:[NSBundle.mainBundle URLForResource:@"lorem" withExtension:@"txt"] usedEncoding:NULL error:NULL]];
NSTextStorage *sharedTextStorage = self.originalTextView.textStorage;
[sharedTextStorage replaceCharactersInRange:NSMakeRange(0, 0) withString:[NSString stringWithContentsOfURL:[NSBundle.mainBundle URLForResource:@"lorem" withExtension:@"txt"] usedEncoding:NULL error:NULL]];


// Create a new text view on the original text storage
NSLayoutManager *lowerLayoutManager = [NSLayoutManager new];
[upperTextStorage addLayoutManager: lowerLayoutManager];
NSLayoutManager *otherLayoutManager = [NSLayoutManager new];
[sharedTextStorage addLayoutManager: otherLayoutManager];

NSTextContainer *firstTextContainer = [NSTextContainer new];
[lowerLayoutManager addTextContainer: firstTextContainer];
NSTextContainer *otherTextContainer = [NSTextContainer new];
[otherLayoutManager addTextContainer: otherTextContainer];

UITextView *firstTextView = [[UITextView alloc] initWithFrame:self.firstContainerView.bounds textContainer:firstTextContainer];
firstTextView.backgroundColor = self.firstContainerView.backgroundColor;
firstTextView.translatesAutoresizingMaskIntoConstraints = YES;
firstTextView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
UITextView *otherTextView = [[UITextView alloc] initWithFrame:self.otherContainerView.bounds textContainer:otherTextContainer];
otherTextView.backgroundColor = self.otherContainerView.backgroundColor;
otherTextView.translatesAutoresizingMaskIntoConstraints = YES;
otherTextView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

firstTextView.scrollEnabled = NO;
otherTextView.scrollEnabled = NO;

[self.firstContainerView addSubview: firstTextView];
self.firstTextView = firstTextView;
[self.otherContainerView addSubview: otherTextView];
self.otherTextView = otherTextView;


// Create a second text view on the new layout manager text storage
NSTextContainer *secondTextContainer = [NSTextContainer new];
[lowerLayoutManager addTextContainer: secondTextContainer];
NSTextContainer *thirdTextContainer = [NSTextContainer new];
[otherLayoutManager addTextContainer: thirdTextContainer];

UITextView *secondTextView = [[UITextView alloc] initWithFrame:self.secondContainerView.bounds textContainer:secondTextContainer];
secondTextView.backgroundColor = self.secondContainerView.backgroundColor;
secondTextView.translatesAutoresizingMaskIntoConstraints = YES;
secondTextView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
UITextView *thirdTextView = [[UITextView alloc] initWithFrame:self.thirdContainerView.bounds textContainer:thirdTextContainer];
thirdTextView.backgroundColor = self.thirdContainerView.backgroundColor;
thirdTextView.translatesAutoresizingMaskIntoConstraints = YES;
thirdTextView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

[self.secondContainerView addSubview: secondTextView];
self.secondTextView = secondTextView;
[self.thirdContainerView addSubview: thirdTextView];
self.thirdTextView = thirdTextView;
}

- (IBAction)endEditing:(UIBarButtonItem *)sender
Expand Down
4 changes: 2 additions & 2 deletions TextKitDemo/Highlighting/TKDHighlightingTextStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

@implementation TKDHighlightingTextStorage
{
NSTextStorage *_imp;
NSMutableAttributedString *_imp;
}

- (id)init
{
self = [super init];

if (self) {
_imp = [NSTextStorage new];
_imp = [NSMutableAttributedString new];
}

return self;
Expand Down

0 comments on commit 5ebb2cd

Please sign in to comment.