Skip to content

Instantly share code, notes, and snippets.

View pratikshabhisikar's full-sized avatar

Pratiksha Bhisikar pratikshabhisikar

View GitHub Profile
#import <Foundation/Foundation.h>
typedef void(^FetchCabsCompletionHandler)(NSMutableArray *outboundCabs, NSMutableArray *inboundCabs, NSError *error);
@class TravelDetails;
@interface FetchCabs : NSObject {
}
-(void) fetchCabsWithTravelDetails:(TravelDetails *) travelDetails completionHandler:(FetchCabsCompletionHandler) completionBlock;
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
static NSString *headerReuseIdentifier = @"TableViewSectionHeaderViewIdentifier";
UITableViewHeaderFooterView *sectionHeaderView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:headerReuseIdentifier];
if (sectionHeaderView != nil) {
// No header view presents in reusable queue. Create a new header view…
}
// Configure header view.
sectionHeaderView.textLabel.text = @"I am header"; // Set your section header corresponding to the parameter section.
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
static NSString *headerReuseIdentifier = @"TableViewSectionHeaderViewIdentifier";
UITableViewHeaderFooterView *sectionHeaderView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:headerReuseIdentifier];
sectionHeaderView.textLabel.text = @"I am header"; // Set your section header corresponding to the parameter section.
return sectionHeaderView;
}
@pratikshabhisikar
pratikshabhisikar / Event Rules
Created October 2, 2012 08:23
NSChat room event rules
1. During the events, no kind of chat takes place. Only it is the speaker speaking on the current topic. Any other kind of chat will be moved to bin and the concerned person will be notified once (by a room owner). In case it is repeated, the person loses the write access for the event.
2. During the events, no questions unrelated to the event topics are to be asked. Since no questions are to be asked unrelated to the event topics, no answers will be provided. Questions asked, if any, unrelated to the event will be moved to bin and the concerned person will be notified once (by a room owner). In case it is repeated, the person loses the write access for the event (done by a room owner). #NOTE: For this, we gotta somehow display the room isn't accepting any questions that time.
3. During the events, No questions related to the ongoing topic are to be asked *while it is in progress*. Questions asked, if any, will be moved to bin and the concerned person will be notified once (by a room owner). In case it i
// Fetch list of places from the GooglePlaces.plist file present in the bundle.
dispatch_queue_t aQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(aQueue, ^{
// Perform some task...
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
});
-(void) reloadTableCellsAtIndexPaths:(NSArray *) indexPaths {
NSArray *visibleTableCells = [self.tableView indexPathsForVisibleRows];
[indexPaths enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id obj, NSUInteger idx, BOOL *stop){
BOOL isVisible = [visibleTableCells containsObject:obj];
if (isVisible) {
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:obj] withRowAnimation:UITableViewRowAnimationFade];
}
}];
}
-(void) buttonPressed:(id) sender {
UIButton *tappedButton = (UIButton *) sender;
// Set all other buttons to unselected state...
// for each button ... button.selected = NO;
// Select the tapped button.
tappedButton.selected = YES;
}
-(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
if (!receivedData) {
receivedData = [[NSMutableData data] retain];
}
[receivedData setLength:0];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
// Start video recording.
BOOL cameraAvailable = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
if (cameraAvailable) {
NSArray *availableMediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
BOOL videoRecordingAvailable = [availableMediaTypes containsObject:(__bridge id) kUTTypeMovie];
if (videoRecordingAvailable) {
- (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.
NSLog(@"%s", __PRETTY_FUNCTION__);
if (loginController.parentViewController == NO) {
// Either login controller doesn't exists (app launch case) or it's already dismissed.
/*
1. instantiate new login controller.
2. present it.