cocoa-touch

How to Check if an NSDate occurs between two other NSDates

I am trying to figure out whether or not the current date falls within a date range using NSDate. For example, you can get the current date/time using NSDate: NSDate rightNow = [NSDate date]; I would then like to use that date to check if it is in the range of 9AM - 5PM. ...

Is it possible to disable floating headers in UITableView with UITableViewStylePlain?

Hi, I'm using a UITableView to layout content 'pages'. I'm using the headers of the table view to layout certain images etc. and I'd prefer it if they didn't float but stayed static as they do when the style is set to UITableViewStyleGrouped. Other then using UITableViewStyleGrouped, is there a way to do this? I'd like to avoid using gr...

Passing a ManagedObjectContext to a second view

I'm writing my first iPhone/Cocoa app. It has two table views inside a navigation view. When you touch a row in the first table view, you are taken to the second table view. I would like the second view to display records from the CoreData entities related to the row you touched in the first view. I have the CoreData data showing up fin...

Cocoa Touch Question. Using KVO in a touch sequence context

I would like to use KVO in the following context: 1) In touchesBegan:withEvent: I alloc/init an instance of an object that I then observe via KVO My intent is to observe varous behaviors of the object throughout its life time. 2) In touchesEnded:withEvent: I assign this instance to an NSMutableArray and release the instance reference ...

How to position view relative to parent?

I have a UIViewController with an MKMapView in it. In viewDidLoad of this controller, I add the MKMapView: [self.view addSubview:mapView]; I want to display this map in a tableview cell. In the tableview controller's cellForRowAtIndexPath:, I do this: [cell addSubview:mapView.view]; where cell is a UITableViewCell. I've set the ...

CocoaTouch equivalent of Java custom protocol handler

I'd like to pretend to be new to CocoaTouch but since I've been using it for over a year I'll just jump right out and claim stoopidity. Is there an easy/elegant way to intercept HTTP calls in CocoaTouch and route them through a custom class. In Java I could implement a custom protocol handler and change the URL protocol from "http:" to s...

shouldStartLoadWithRequest is not called in my iPhone App

I have a view controller with a UIWebView controller. I'm trying to get the javascript inside the html content of the web view to pass some information to my objective c code. I came across a number of examples online that set window.location in a javascript function and then catch the event generated by setting the view controller to be...

How do you wrap up a BOOL for KVC in Cocoa/Obj-C?

I'm using KVC to iterating through a few views. Having trouble setting BOOL properties: [self setValue:YES forKeyPath:[NSString stringWithFormat:@"myView%d.userInteractionEnabled", n]]; I get: warning: passing argument 1 of 'setValue:forKeyPath:' makes pointer from integer without a cast. There is no [NSValue valueWithBool:YES] or si...

Objective-C not recognizing .h?

I have the following in a project named testApp: (testAppViewController is the valid name of my view controller in the project) PrevView.h #import <UIKit/UIKit.h> #import "testAppViewController.h" @interface PrevView : UIView { testAppViewController *viewController; } @property (nonatomic,retain) testAppViewController *viewContro...

Setting UITableView headers from NSFetchedResultsController

I have a NSFetchedResultsController which is fetching objects from a NSManagedObjectContext. I'm using the results to populate a UITableView. I'm filtering with these two sort descriptors. NSSortDescriptor *lastOpened = [[NSSortDescriptor alloc] initWithKey:@"lastOpened" ascending:NO]; NSSortDescriptor *titleDescriptor = [[N...

IPhone Connectivity Testing: How do I force it to lose connection?

Apple wants me to give the user a friendly apology if I can't find an internet connection. Using the Reachability Demo, this was easy enough. I want to take it a step further and monitor for a connection loss. The demo has this functionality, but I can't figure out how to shut my connection off to test if it works. How would I go about ...

Delete/Reset all entries in Core Data?

Do you know of any way to delete all of the entries stored in Core Data? My schema should stay the same; I just want to reset it to blank. Edit I'm looking to do this programmatically so that a user can essentially hit a reset button. ...

UIView angle in circular motion

I have a requirement where I will move my finger in the circular motion on the iphone touch screen and i need the current angle parallely. I will apply this angle to my uiview and will rotate it. PLease, can anybody help. Thanks in advance ...

iphone: creating image without allocating new memory

the pointer data if pointing to some image generated by an iphone application. Does anybody now if using CGBitmapContextCreate make a copy of this data or does it use the image "in place"? Ideally, I'd like to reuse the information in data* and not create any additional copy of this image. void* data = <my data>; CGColorSpaceRef color...

Detect if one position in Array is already initiated

I need to check specific positions in an NSArray to see if they have already been initialized, but I am having trouble. I tried to do the following, but it causes my application to crash! if ((NSMutableArray *)[arrAllBlocks objectAtIndex:iLine] == nil) { [arrAllBlocks insertObject:[[NSMutableArray alloc] init] atIndex:iLine]; } NS...

viewDidLoad getting called twice on rootViewController at launch

Anyone know why this root View Controller's viewDidLoad is being called twice at launch? It's driving me nuts! here's the stack trace from first time through viewDidLoad: #0 0x0000276a in -[RootViewController viewDidLoad] at RootViewController.m:71 #1 0x3097548f in -[UIViewController view] #2 0x00002734 in -[RootViewController init...

Optimizing CLLocationManager/CoreLocation to retrieve data points faster on the iPhone

Hi all, I'm currently using CoreLocation + CLLocationManager in order to compare a users current location to N amount of other locations. The problem I'm facing is I'm dealing with urban areas where locations are close to each other, so I need to pin point the location of the user as accurately as the device allows without sacrificing t...

Generating forms from models (a la django ModelForms) in Objective-C

I'm taking the plunge into iPhone development after about two years working with django. As I've done tutorials and read documentation, one of the things that strikes me as inconvenient about the various libraries used in iPhone development is the amount of repetition required when creating user input forms for data models. I know of...

Animating Touches to Objects - can I get object of touched view?

I'd like to get a reference to the object whose view was touched on the iPhone. I'm probably just approaching this the wrong way so let me try to explain what trying to do... I have various instances of a sub-classed UIImageView with some custom value properties. The user can touch and move them. Depending on where they go I'd like to...

Indexed Relationships in Core Data

I'm just starting out with using Core Data on the iPhone SDK and I'm looking into saving an ordered list, something like an array. However, relationships in Core Data are expressed as Sets when retrieved. This makes it difficult to save the order in which the objects are positioned. A good example would be data items in table view when...