Permalink
Browse files

Cleaned up some unneeded code

  • Loading branch information...
1 parent dc254e7 commit 59ba875bb9c01720299f2cd905f4e00eceab06e5 Sahil Desai committed Jul 26, 2009
@@ -8,7 +8,6 @@
#import <UIKit/UIKit.h>
#import "CJSONDeserializer.h"
-#import "Protocols.h"
@class SettingsViewController;
@class FavouritesViewController;
@@ -33,8 +32,8 @@
NSString *searchQuery;
NSMutableArray *resultsArray;
- NSMutableArray *favouritesArray;
- NSMutableArray *favouritesInfoArray;
+ NSMutableArray *favouritesArray;
+ NSMutableArray *resultObjectsArray;
BOOL loading;
UIActivityIndicatorView *activityIndicator;
@@ -9,6 +9,7 @@
#define AVAILABLE 0
#define MAYBE 1
#define TAKEN 2
+#define TLD 3
#define DURATION 0.2f
#import "MainViewController.h"
@@ -290,21 +291,34 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
ResultWrapper *wrapper = [[ResultWrapper alloc] init];
[wrapper setDomainName:domain];
- [wrapper setAvailability:availability];
if([availability isEqualToString:@"available"]){
[wrapper setImageType:AVAILABLE];
+ [wrapper setAvailability:@"available"];
}
else if([availability isEqualToString:@"maybe"]) {
- [wrapper setImageType:MAYBE];
+ [wrapper setImageType:MAYBE];
+ [wrapper setAvailability:@"maybe"];
}
else if([availability isEqualToString:@"taken"]) {
[wrapper setImageType:TAKEN];
+ [wrapper setAvailability:@"taken"];
}
+ else if([availability isEqualToString:@"tld"]) {
+ [wrapper setImageType:TLD];
+ [wrapper setAvailability:@"top-level domain"];
+ }
+ else if([availability isEqualToString:@"known"]) {
+ [wrapper setImageType:TLD];
+ [wrapper setAvailability:@"subdomain"];
+ }
else {
[wrapper setImageType:2];
+ [wrapper setImageType:TAKEN];
+ [wrapper setAvailability:availability];
}
-
+
+
[cell setResultWrapper:wrapper];
BOOL starred = [self isFavourite:domain];
@@ -393,7 +407,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
ResultViewController *resultViewController = [[ResultViewController alloc] initWithStyle:UITableViewStyleGrouped];
ResultWrapper *wrapper = [currentCell getResultWrapper];
- [resultViewController setDomainName:wrapper.domainName];
+ [resultViewController setDomain:wrapper.domainName];
+ [resultViewController setStatus:wrapper.availability];
[self.navigationController pushViewController:resultViewController animated:YES];
View
No changes.
@@ -10,9 +10,11 @@
@interface ResultViewController : UITableViewController {
- NSString *domainName;
+ NSString *domain;
+ NSString *status;
}
-@property (nonatomic, retain) NSString *domainName;
+@property (nonatomic, retain) NSString *domain;
+@property (nonatomic, retain) NSString *status;
@end
@@ -11,7 +11,8 @@
@implementation ResultViewController
-@synthesize domainName;
+@synthesize domain;
+@synthesize status;
- (id)initWithStyle:(UITableViewStyle)style {
if (self = [super initWithStyle:style]) {
@@ -21,7 +22,7 @@ - (id)initWithStyle:(UITableViewStyle)style {
- (void)viewDidLoad {
[super viewDidLoad];
- [self setTitle:domainName];
+// [self setTitle:domain];
}
- (void)viewWillAppear:(BOOL)animated {
@@ -50,6 +51,43 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
+ [[cell textLabel] setTextAlignment:UITextAlignmentCenter];
+
+ if(indexPath.row == 0){
+ [[cell textLabel] setFont:[UIFont boldSystemFontOfSize:28]];
+ [[cell textLabel] setText:domain];
+ }
+ else if(indexPath.row == 1) {
+ [[cell textLabel] setFont:[UIFont systemFontOfSize:14.0]];
+ if([status isEqualToString:@"available"]){
+ [[cell textLabel] setTextColor:[UIColor greenColor]];
+ [[cell textLabel] setText:@"This domain is available."];
+ }
+ if([status isEqualToString:@"maybe"]){
+ [[cell textLabel] setTextColor:[UIColor greenColor]];
+ [[cell textLabel] setText:@"This domain might be available."];
+ }
+ else if([status isEqualToString:@"taken"]){
+ [[cell textLabel] setTextColor:[UIColor redColor]];
+ [[cell textLabel] setText:@"This domain is taken."];
+ }
+ else if([status isEqualToString:@"unavailable"]){
+ [[cell textLabel] setTextColor:[UIColor redColor]];
+ [[cell textLabel] setText:@"This domain is not available."];
+ }
+ else if([status isEqualToString:@"top-level domain"]){
+ [[cell textLabel] setTextColor:[UIColor darkGrayColor]];
+ [[cell textLabel] setText:@"Top-Level Domain."];
+ }
+ else if([status isEqualToString:@"subdomain"]){
+ [[cell textLabel] setTextColor:[UIColor darkGrayColor]];
+ [[cell textLabel] setText:[NSString stringWithFormat:@"Subdomain of %@.",domain]];
+ }
+ }
+ else if(indexPath.row == 2) {
+ [[cell textLabel] setFont:[UIFont systemFontOfSize:14]];
+ [[cell textLabel] setText:@"Register / More information"];
+ }
return cell;
}
View
@@ -8,7 +8,7 @@
#import <UIKit/UIKit.h>
-@interface ResultWrapper : NSObject {
+@interface ResultWrapper : NSObject <NSCoding> {
NSString *domainName;
NSString *availability;
UIImage *image;
View
@@ -9,13 +9,15 @@
#define AVAILABLE 0
#define MAYBE 1
#define TAKEN 2
+#define TLD 3
#import "ResultWrapper.h"
#import "DomainrAppDelegate.h"
static UIImage *availableImage;
static UIImage *maybeImage;
static UIImage *takenImage;
+static UIImage *tldImage;
@implementation ResultWrapper
@@ -24,12 +26,38 @@ @implementation ResultWrapper
@synthesize imageType;
@synthesize availability;
+- (void)dealloc {
+ [image release];
+ [super dealloc];
+}
+
+ (void)initialize {
if (self == [ResultWrapper class]) {
availableImage = [[UIImage imageNamed:@"available.png"] retain];
maybeImage = [[UIImage imageNamed:@"maybe.png"] retain];
takenImage = [[UIImage imageNamed:@"taken.png"] retain];
+ tldImage = [[UIImage imageNamed:@"tld.png"] retain];
+ }
+}
+
+- (id) initWithCoder: (NSCoder *)coder
+{
+ if (self = [super init])
+ {
+ [self setDomainName: [coder decodeObjectForKey:@"name"]];
+ [self setImage: [coder decodeObjectForKey:@"image"]];
+// [self setImageType: [coder decodeObjectForKey:@"imageType"]];
+ [self setAvailability: [coder decodeObjectForKey:@"availability"]];
}
+ return self;
+}
+
+- (void) encodeWithCoder: (NSCoder *)coder
+{
+ [coder encodeObject: domainName forKey:@"name"];
+ [coder encodeObject: image forKey:@"image"];
+// [coder encodeObject: imageType forKey:@"imageType"];
+ [coder encodeObject: availability forKey:@"availability"];
}
- (UIImage *)image {
@@ -45,16 +73,16 @@ - (UIImage *)image {
case TAKEN:
image = takenImage;
break;
+ case TLD:
+ image = tldImage;
+ break;
default:
break;
}
}
return image;
}
-- (void)dealloc {
- [image release];
- [super dealloc];
-}
+
@end
@@ -15,6 +15,7 @@
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; };
BA2473430FCBB321002C53A8 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = BA2473420FCBB321002C53A8 /* Reachability.m */; };
BA786CD20FD332FB00C20BD5 /* FavouritesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BA786CD10FD332FB00C20BD5 /* FavouritesViewController.m */; };
+ BA8A7D850FE4E44D00D5907E /* tld.png in Resources */ = {isa = PBXBuildFile; fileRef = BA8A7D840FE4E44D00D5907E /* tld.png */; };
BA9D0D310FCA4E7100E2B262 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BA9D0D300FCA4E7100E2B262 /* MainViewController.m */; };
BA9D0D480FCA4FC100E2B262 /* CDataScanner.m in Sources */ = {isa = PBXBuildFile; fileRef = BA9D0D390FCA4FC000E2B262 /* CDataScanner.m */; };
BA9D0D490FCA4FC100E2B262 /* CDataScanner_Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = BA9D0D3B0FCA4FC000E2B262 /* CDataScanner_Extensions.m */; };
@@ -59,9 +60,9 @@
8D1107310486CEB800E47090 /* Domainr-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Domainr-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
BA2473410FCBB321002C53A8 /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reachability.h; sourceTree = "<group>"; };
BA2473420FCBB321002C53A8 /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = "<group>"; };
- BA786C610FD27F2600C20BD5 /* Protocols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Protocols.h; sourceTree = "<group>"; };
BA786CD00FD332FB00C20BD5 /* FavouritesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FavouritesViewController.h; sourceTree = "<group>"; };
BA786CD10FD332FB00C20BD5 /* FavouritesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FavouritesViewController.m; sourceTree = "<group>"; };
+ BA8A7D840FE4E44D00D5907E /* tld.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tld.png; sourceTree = "<group>"; };
BA9D0D2F0FCA4E7100E2B262 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = "<group>"; };
BA9D0D300FCA4E7100E2B262 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = "<group>"; };
BA9D0D380FCA4FC000E2B262 /* CDataScanner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDataScanner.h; sourceTree = "<group>"; };
@@ -130,7 +131,6 @@
080E96DDFE201D6D7F000001 /* Classes */ = {
isa = PBXGroup;
children = (
- BA786C610FD27F2600C20BD5 /* Protocols.h */,
BA2473410FCBB321002C53A8 /* Reachability.h */,
BA2473420FCBB321002C53A8 /* Reachability.m */,
1D3623240D0F684500981E51 /* DomainrAppDelegate.h */,
@@ -166,8 +166,8 @@
children = (
BA9D0DC20FCA5ED000E2B262 /* Beacon */,
BA9D0D370FCA4FC000E2B262 /* CJSON */,
- BA9D0D500FCA4FCF00E2B262 /* images */,
080E96DDFE201D6D7F000001 /* Classes */,
+ BA9D0D500FCA4FCF00E2B262 /* images */,
29B97317FDCFA39411CA2CEA /* Resources */,
29B97315FDCFA39411CA2CEA /* Other Sources */,
29B97323FDCFA39411CA2CEA /* Frameworks */,
@@ -237,6 +237,7 @@
isa = PBXGroup;
children = (
BA9D11150FCA8F4300E2B262 /* icon.png */,
+ BA8A7D840FE4E44D00D5907E /* tld.png */,
BA9D0F180FCA69F000E2B262 /* taken.png */,
BA9D0EF00FCA67B600E2B262 /* maybe.png */,
BA9D0EF20FCA67BA00E2B262 /* available.png */,
@@ -312,6 +313,7 @@
BA9D11160FCA8F4300E2B262 /* icon.png in Resources */,
BAC9194F0FD24357008A128C /* bubblestar.png in Resources */,
BAC919650FD24807008A128C /* star_pressed.png in Resources */,
+ BA8A7D850FE4E44D00D5907E /* tld.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -421,7 +423,8 @@
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
- "PROVISIONING_PROFILE[sdk=iphoneos*]" = "F868D3EE-A0BB-4C9B-9FE4-F4A79700CAB5";
+ PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = YES;
+ "PROVISIONING_PROFILE[sdk=iphoneos*]" = "AA8F3F88-0652-444C-A4F7-48F779DC3373";
SDKROOT = iphoneos3.0;
};
name = Debug;
View
BIN tld.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 59ba875

Please sign in to comment.