Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
clean up for lint tool
Browse files Browse the repository at this point in the history
  • Loading branch information
jwang committed Jul 16, 2011
1 parent a59c4b2 commit b16f136
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/Three20Core/Headers/NSDataAdditions.h
Expand Up @@ -35,10 +35,10 @@

/**
* Create an NSData from a base64 encoded representation
*
* Padding '=' characters are optional. Whitespace is ignored.
* @return the NSData object
*/
+ (id)dataWithBase64EncodedString:(NSString *)string; // Padding '=' characters are optional. Whitespace is ignored.
+ (id)dataWithBase64EncodedString:(NSString *)string;

/**
* Marshal the data into a base64 encoded representation
Expand Down
18 changes: 11 additions & 7 deletions src/Three20Core/Sources/NSDataAdditions.m
Expand Up @@ -63,10 +63,11 @@ - (NSString*)sha1Hash {
// base64 code found on http://www.cocoadev.com/index.pl?BaseSixtyFour
// where the poster released it to public domain
// style not exactly congruous with normal three20 style, but kept mostly intact with the original
static const char encodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char encodingTable[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

+ (NSData*)dataWithBase64EncodedString:(NSString *)string;
{
///////////////////////////////////////////////////////////////////////////////////////////////////
+ (NSData*)dataWithBase64EncodedString:(NSString *)string {
if ([string length] == 0)
return [NSData data];

Expand Down Expand Up @@ -129,8 +130,8 @@ + (NSData*)dataWithBase64EncodedString:(NSString *)string;
return [NSData dataWithBytesNoCopy:bytes length:length];
}

- (NSString *)base64Encoding;
{
///////////////////////////////////////////////////////////////////////////////////////////////////
- (NSString *)base64Encoding {
if ([self length] == 0)
return @"";

Expand All @@ -147,7 +148,8 @@ - (NSString *)base64Encoding;
while (bufferLength < 3 && i < [self length])
buffer[bufferLength++] = ((char *)[self bytes])[i++];

// Encode the bytes in the buffer to four characters, including padding "=" characters if necessary.
// Encode the bytes in the buffer to four characters,
// including padding "=" characters if necessary.
characters[length++] = encodingTable[(buffer[0] & 0xFC) >> 2];
characters[length++] = encodingTable[((buffer[0] & 0x03) << 4) | ((buffer[1] & 0xF0) >> 4)];
if (bufferLength > 1)
Expand All @@ -158,7 +160,9 @@ - (NSString *)base64Encoding;
else characters[length++] = '=';
}

return [[[NSString alloc] initWithBytesNoCopy:characters length:length encoding:NSASCIIStringEncoding freeWhenDone:YES] autorelease];
return [[[NSString alloc] initWithBytesNoCopy:characters length:length
encoding:NSASCIIStringEncoding freeWhenDone:YES]
autorelease];
}
// end recycled base64 code
///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
36 changes: 20 additions & 16 deletions src/Three20Core/Sources/NSDateAdditions.m
Expand Up @@ -53,7 +53,9 @@ + (NSDate*)dateWithToday {
///////////////////////////////////////////////////////////////////////////////////////////////////
- (NSDate*)dateAtMidnight {
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *comps = [gregorian components:(NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit) fromDate:[NSDate date]];
NSDateComponents *comps = [gregorian components:
(NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit)
fromDate:[NSDate date]];
NSDate *midnight = [gregorian dateFromComponents:comps];
[gregorian release];
return midnight;
Expand Down Expand Up @@ -146,31 +148,33 @@ - (NSString*)formatRelativeTime {
if (elapsed > 0) {
if (elapsed <= 1) {
return TTLocalizedString(@"in just a moment", @"");
} else if (elapsed < TT_MINUTE) {
}
else if (elapsed < TT_MINUTE) {
int seconds = (int)(elapsed);
return [NSString stringWithFormat:TTLocalizedString(@"in %d seconds", @""), seconds];

} else if (elapsed < 2*TT_MINUTE) {

}
else if (elapsed < 2*TT_MINUTE) {
return TTLocalizedString(@"in about a minute", @"");
} else if (elapsed < TT_HOUR) {
}
else if (elapsed < TT_HOUR) {
int mins = (int)(elapsed/TT_MINUTE);
return [NSString stringWithFormat:TTLocalizedString(@"in %d minutes", @""), mins];
} else if (elapsed < TT_HOUR*1.5) {
}
else if (elapsed < TT_HOUR*1.5) {
return TTLocalizedString(@"in about an hour", @"");
} else if (elapsed < TT_DAY) {
}
else if (elapsed < TT_DAY) {
int hours = (int)((elapsed+TT_HOUR/2)/TT_HOUR);
return [NSString stringWithFormat:TTLocalizedString(@"in %d hours", @""), hours];
} else {
}
else {
return [self formatDateTime];
}
} else {
}
}
else {
elapsed = -elapsed;

if (elapsed <= 1) {
return TTLocalizedString(@"just a moment ago", @"");

Expand Down
7 changes: 4 additions & 3 deletions src/Three20Core/Sources/NSStringAdditions.m
Expand Up @@ -144,9 +144,10 @@ - (NSString*)stringByAddingQueryDictionary:(NSDictionary*)query {
///////////////////////////////////////////////////////////////////////////////////////////////////
- (id)urlEncoded {
CFStringRef cfUrlEncodedString = CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)self,
NULL, (CFStringRef)@"!*’();:@&=$,/?%#[]",
kCFStringEncodingUTF8);
(CFStringRef)self,NULL,
(CFStringRef)@"!*’();:@&=$,/?%#[]",
kCFStringEncodingUTF8);

NSString *urlEncoded = [NSString stringWithString:(NSString *)cfUrlEncodedString];
CFRelease(cfUrlEncodedString);
return urlEncoded;
Expand Down
3 changes: 2 additions & 1 deletion src/Three20Style/Sources/TTStyledLayout.m
Expand Up @@ -377,7 +377,8 @@ - (void)breakLine {
// XXXjoe Support top, bottom, and center alignment also
if (frame.height < _lineHeight) {
UIFont* font = frame.font ? frame.font : _font;
[self offsetFrame:frame by:(_lineHeight - (frame.height - (lowestDescender - font.descender)))];
[self offsetFrame:frame by:(_lineHeight - (frame.height -
(lowestDescender - font.descender)))];
}
frame = frame.nextFrame;
}
Expand Down
19 changes: 11 additions & 8 deletions src/Three20Style/Sources/TTStyledTextParser.m
Expand Up @@ -274,7 +274,8 @@ - (NSData *) parser:(NSXMLParser *)parser
- (void)parseText:(NSString*)string URLs:(BOOL)shouldParseURLs {
if (shouldParseURLs) {
[self parseURLs:string];
} else {
}
else {
TTStyledTextNode* node = [[[TTStyledTextNode alloc] initWithText:string] autorelease];
[self addNode:node];
}
Expand Down Expand Up @@ -303,7 +304,7 @@ - (void)parseText:(NSString*)string {
NSCharacterSet* newLines = [NSCharacterSet newlineCharacterSet];
NSInteger stringIndex = 0;
NSInteger length = string.length;

while (1) {
NSRange searchRange = NSMakeRange(stringIndex, length - stringIndex);
NSRange range = [string rangeOfCharacterFromSet:newLines options:0 range:searchRange];
Expand All @@ -312,22 +313,24 @@ - (void)parseText:(NSString*)string {
NSRange textRange = NSMakeRange(stringIndex, range.location - stringIndex);
NSString* substr = [string substringWithRange:textRange];
[self parseText:substr URLs:_parseURLs];

// Add a line break node after the text
TTStyledLineBreakNode* br = [[[TTStyledLineBreakNode alloc] init] autorelease];
[self addNode:br];

stringIndex = stringIndex + substr.length + 1;

} else {

}
else {
// Find all text until the end of hte string and parse it
NSString* substr = [string substringFromIndex:stringIndex];
[self parseText:substr URLs:_parseURLs];
break;
}
}

} else {

}
else {
[self parseText:string URLs:_parseURLs];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Three20UI/Headers/TTTableViewController.h
Expand Up @@ -93,7 +93,7 @@
* A Boolean value indicating if the controller clears the selection when the table appears.
* Default is YES.
*/
@property(nonatomic) BOOL clearsSelectionOnViewWillAppear;
@property (nonatomic) BOOL clearsSelectionOnViewWillAppear;

/**
* Initializes and returns a controller having the given style.
Expand Down
5 changes: 3 additions & 2 deletions src/Three20UI/Sources/TTStyledTextTableItemCell.m
Expand Up @@ -79,12 +79,13 @@ + (CGFloat)tableView:(UITableView*)tableView rowHeightForObject:(id)object {
if (item.URL) {
padding += kDisclosureIndicatorWidth;
}

CGFloat margin = item.margin.left + item.margin.right;

item.text.width = tableView.width - padding - margin;

return item.text.height + item.padding.top + item.padding.bottom + item.margin.top + item.margin.bottom;
return item.text.height + item.padding.top + item.padding.bottom
+ item.margin.top + item.margin.bottom;
}


Expand Down
6 changes: 3 additions & 3 deletions src/Three20UI/Sources/TTTableViewController.m
Expand Up @@ -641,18 +641,18 @@ - (UITableView*)tableView {
_tableView = [[TTTableView alloc] initWithFrame:self.view.bounds style:_tableViewStyle];
_tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth
| UIViewAutoresizingFlexibleHeight;

UIColor* separatorColor = _tableViewStyle == UITableViewStyleGrouped
? TTSTYLEVAR(tableGroupedCellSeparatorColor)
: TTSTYLEVAR(tablePlainCellSeparatorColor);
if (separatorColor) {
_tableView.separatorColor = separatorColor;
}

_tableView.separatorStyle = _tableViewStyle == UITableViewStyleGrouped
? TTSTYLEVAR(tableGroupedCellSeparatorStyle)
: TTSTYLEVAR(tablePlainCellSeparatorStyle);

UIColor* backgroundColor = _tableViewStyle == UITableViewStyleGrouped
? TTSTYLEVAR(tableGroupedBackgroundColor)
: TTSTYLEVAR(tablePlainBackgroundColor);
Expand Down
10 changes: 6 additions & 4 deletions src/Three20UI/Sources/TTWebController.m
Expand Up @@ -321,8 +321,10 @@ - (void)restoreView:(NSDictionary*)state {
///////////////////////////////////////////////////////////////////////////////////////////////////
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request
navigationType:(UIWebViewNavigationType)navigationType {
if ([_delegate respondsToSelector:@selector(webController:webView:shouldStartLoadWithRequest:navigationType:)] &&
![_delegate webController:self webView:webView shouldStartLoadWithRequest:request navigationType:navigationType]) {
if ([_delegate respondsToSelector:
@selector(webController:webView:shouldStartLoadWithRequest:navigationType:)] &&
![_delegate webController:self webView:webView
shouldStartLoadWithRequest:request navigationType:navigationType]) {
return NO;
}

Expand Down Expand Up @@ -417,7 +419,7 @@ - (void)setHeaderView:(UIView*)headerView {
_headerView = [headerView retain];
_headerView.frame = CGRectMake(0, 0, _webView.width, _headerView.height);

self.view;
//self.view;
UIView* scroller = [_webView descendantOrSelfWithClass:NSClassFromString(@"UIScroller")];
UIView* docView = [scroller descendantOrSelfWithClass:NSClassFromString(@"UIWebDocumentView")];
[scroller addSubview:_headerView];
Expand All @@ -443,7 +445,7 @@ - (void)openURL:(NSURL*)URL {

///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)openRequest:(NSURLRequest*)request {
self.view;
//self.view;
[_webView loadRequest:request];
}

Expand Down

0 comments on commit b16f136

Please sign in to comment.