Skip to content

Commit

Permalink
Added episode 59 sample code
Browse files Browse the repository at this point in the history
  • Loading branch information
subdigital committed Mar 28, 2013
1 parent 40faa17 commit 29b5a46
Show file tree
Hide file tree
Showing 592 changed files with 75,482 additions and 0 deletions.
@@ -0,0 +1,23 @@
.DS_Store
*.swp
*~
*~.nib
*.orig
build/
deliapp.build
Debug-iphonesimulator

*.pbxuser
*.perspective
*.perspectivev3
*.mode1v3
*.mode2v3
xcuserdata
project.xcworkspace
.idea
pkg
build.output
test-reports
kif-screenshots
kif.error
tags

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,15 @@
//
// NSCAppDelegate.h
// NSScreencastChat
//
// Created by ben on 3/9/13.
// Copyright (c) 2013 NSScreencast. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface NSCAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end
@@ -0,0 +1,44 @@
//
// NSCAppDelegate.m
// NSScreencastChat
//
// Created by ben on 3/9/13.
// Copyright (c) 2013 NSScreencast. All rights reserved.
//

#import "NSCAppDelegate.h"

@implementation NSCAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
@@ -0,0 +1,21 @@
//
// NSCChatViewController.h
// NSScreencastChat
//
// Created by ben on 3/10/13.
// Copyright (c) 2013 NSScreencast. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MessagesViewController.h"
#import "WindowsAzureMobileServices.h"
#import "NSCRoom.h"
#import "NSCUser.h"

@interface NSCChatViewController : MessagesViewController

@property (nonatomic, strong) MSClient *client;
@property (nonatomic, strong) NSCUser *user;
@property (nonatomic, strong) NSCRoom *room;

@end
@@ -0,0 +1,42 @@
//
// NSCChatViewController.m
// NSScreencastChat
//
// Created by ben on 3/10/13.
// Copyright (c) 2013 NSScreencast. All rights reserved.
//

#import "NSCChatViewController.h"
#import "MessageInputView.h"
#import "NSCMessage.h"

@interface NSCChatViewController ()

@property (nonatomic, strong) NSMutableArray *messages;
@property (nonatomic, strong) NSTimer *fetchTimer;
@property (nonatomic, strong) NSDate *lastFetchDate;

@end

@implementation NSCChatViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.title = self.room.name;

// TODO
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}

- (void)fetchMessages {
// TODO
}

@end
@@ -0,0 +1,13 @@
//
// NSCLobbyViewController.h
// NSScreencastChat
//
// Created by ben on 3/9/13.
// Copyright (c) 2013 NSScreencast. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface NSCLobbyViewController : UITableViewController

@end
@@ -0,0 +1,93 @@
//
// NSCLobbyViewController.m
// NSScreencastChat
//
// Created by ben on 3/9/13.
// Copyright (c) 2013 NSScreencast. All rights reserved.
//

#import "NSCLobbyViewController.h"
#import "WindowsAzureMobileServices.h"
#import "NSCRoom.h"
#import "NSCSignInViewController.h"
#import "NSCChatViewController.h"

typedef void (^RoomNameBlock)(NSString *name);

@interface NSCLobbyViewController () <UIAlertViewDelegate>

@property (nonatomic, strong) RoomNameBlock roomNameBlock;
@property (nonatomic, strong) NSCRoom *selectedRoom;
@property (nonatomic, strong) MSClient *client;
@property (nonatomic, strong) NSMutableArray *rooms;

@end

@implementation NSCLobbyViewController

- (void)viewDidLoad {
[super viewDidLoad];

self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(onRefresh:) forControlEvents:UIControlEventValueChanged];

[self setupClient];
[self onRefresh:nil];
}

- (void)onRefresh:(id)sender {
[self.refreshControl beginRefreshing];
[self fetchRooms];
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}


- (void)setupClient {
// TODO
}

- (IBAction)addRoomTapped:(id)sender {
// TODO
}

- (void)fetchRooms {
// TODO
}


#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.rooms.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

NSCRoom *room = self.rooms[indexPath.row];
cell.textLabel.text = room.name;

NSString *participantText = [NSString stringWithFormat:@"%d participant%@", room.participantCount, (room.participantCount == 1 ? @"" : @"s")];
cell.detailTextLabel.text = participantText;

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

return cell;
}


#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

@end
@@ -0,0 +1,22 @@
//
// NSCMessage.h
// NSScreencastChat
//
// Created by ben on 3/23/13.
// Copyright (c) 2013 NSScreencast. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSCMessage : NSObject

@property (nonatomic, assign) NSInteger messageId;
@property (nonatomic, assign) NSInteger roomId;
@property (nonatomic, copy) NSString *author;
@property (nonatomic, copy) NSString *userId;
@property (nonatomic, copy) NSString *text;

+ (NSCMessage *)messageWithDictionary:(NSDictionary *)dictionary;
- (NSDictionary *)attributes;

@end
@@ -0,0 +1,43 @@
//
// NSCMessage.m
// NSScreencastChat
//
// Created by ben on 3/23/13.
// Copyright (c) 2013 NSScreencast. All rights reserved.
//

#import "NSCMessage.h"

@implementation NSCMessage

+ (NSCMessage *)messageWithDictionary:(NSDictionary *)dictionary {
NSCMessage *msg = [[NSCMessage alloc] init];
msg.messageId = [dictionary[@"id"] intValue];
msg.roomId = [dictionary[@"roomId"] intValue];
msg.text = dictionary[@"text"];
msg.author = dictionary[@"author"];
msg.userId = dictionary[@"userId"];
return msg;
}

- (NSDictionary *)attributes {
return @{
@"text": self.text,
@"roomId": @(self.roomId),
};
}

- (NSUInteger)hash {
return [[NSString stringWithFormat:@"NSCRMessage:%d", self.messageId] hash];
}

- (BOOL)isEqual:(id)object {
if (![object isKindOfClass:[NSCMessage class]]) {
return NO;
}

NSCMessage *other = (NSCMessage *)object;
return other.messageId == self.messageId;
}

@end
@@ -0,0 +1,19 @@
//
// NSCRoom.h
// NSScreencastChat
//
// Created by ben on 3/10/13.
// Copyright (c) 2013 NSScreencast. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSCRoom : NSObject

@property (nonatomic, assign) NSUInteger roomId;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, assign) NSUInteger participantCount;

- (id)initWithDictionary:(NSDictionary *)dictionary;

@end
@@ -0,0 +1,28 @@
//
// NSCRoom.m
// NSScreencastChat
//
// Created by ben on 3/10/13.
// Copyright (c) 2013 NSScreencast. All rights reserved.
//

#import "NSCRoom.h"

@implementation NSCRoom

- (id)initWithDictionary:(NSDictionary *)dictionary {
self = [super init];
if (self) {
self.roomId = [dictionary[@"id"] intValue];
self.name = dictionary[@"name"];
self.participantCount = [dictionary[@"participantCount"] intValue];
}

return self;
}

- (NSDictionary *)attributes {
return @{@"name": self.name};
}

@end
@@ -0,0 +1,17 @@
//
// NSCSignInViewController.h
// NSScreencastChat
//
// Created by ben on 3/10/13.
// Copyright (c) 2013 NSScreencast. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "WindowsAzureMobileServices.h"

@interface NSCSignInViewController : UIViewController

/* Required to be set by the presenting view controller before view controller is presented. */
@property (nonatomic, strong) MSClient *client;

@end

0 comments on commit 29b5a46

Please sign in to comment.