I'm getting the slope of a line bounded by two points
float slopeXY(CGPoint p1, CGPoint p2)
{
return ((p2.y - p1.y) / (p2.x - p1.x));
}
If I give it a zero-sized line,
CGPoint p1 = CGPointMake(0, 10);
CGPoint p2 = CGPointMake(0, 10);
float sxy = slopeXY(p1, p2);
I don't get a divide by zero error.
...
Hello all, I've built a very cool looking animation for an end-game state in my (very first) app using CALayers that i'm now looking for a way to speed up - on a 3G iPhone this runs at ~15fps which is ok but on the 3GS it runs at 60fps which looks silky. set-up of the layers/animations below:
The 'background' of the app has two layers e...
Currently the left bar button default value is the title of the view that loaded the current one, in other words the view to be shown when the button is pressed (back button).
I want to change the text shown on the button to something else.
I tried putting the following line of code in the view controller's viewDidLoad method but it do...
I have a plugin written entirely in Python using PyObjC whose core classes I need to convert to Objective-C. One of them basically just loads up a Python module and executes a specific function, passing it keyword arguments. In PyObjC, this was extremely.
However, I'm having difficulty figuring out how to do the same thing using the P...
Hi Guys,
First off, please forgive the stupidness of this question but Im not from a C/C++ background. I'm a little unclear about what the difference in roles between the .h and .m files when it comes to properties.
I understand the concept of interfaces, and I see that in part the .h file is an interface for the implementation, but ...
I have a method in a UIViewController of my iPhone application (inside a UINavigationController) that is called whenever a row is selected in the table in the ViewController's view. In this method, I access array of "Dream"'s stored in an instance field dreamsArray, which contains NSManagedObjects from my database. I can access objects f...
Hi,
I'm amused by a strange error that I'm encountering in my program.
I have a tableViewController with a navigationBar. When the user clicks on an ADD button on the navigationBar, they're presented with a modal tableViewController. This viewController has a CANCEL button on its navigationBar (which dismisses the viewController via de...
It sure seems like the Xcode debugger has been playing a dirty trick on me for the last couple hours.
I was working with this code which has--in hindsight--a pretty obvious bug, but it wasn't obvious at the time:
- (UIImage*)loadBundleImage:(NSString*)imageName {
NSBundle* bundle = [NSBundle mainBundle];
NSString* path = [bu...
Hi all
I'd like to build a cocoa app and would like to have it opened on request. For better understanding you should look at evernote. It has helper app that sits in status bar and has it's own status item.
Evernote's application bundle shows EvernoteHelper executable. How would i go about creating such executable in XCode project? S...
Hi, i'm trying to program a drawer function into Smultron (an open source code editor) but i'm having a bit of trouble with it. I keep on getting an error that says:
2009-09-20 12:43:06.067 Smultron[4481:a0f] -[SMLProject directoryDrawer]: unrecognized selector sent to instance 0x2003ea6c0
Now in SMLProject on interface builder I conn...
Is there a way to determine the line of code a certain method was called from? I
...
Hi, i'm trying to get a Outline view to display a directory, now I've edited the example from Apple to make it work from any directory I set, except when expanding any node I get "EXEC_BAD_ACCESS" from the NSOutlineView class.
Here is the header file:
#import <Cocoa/Cocoa.h>
@interface SMLDirectoryDataSource : NSObject {
NSString ...
The following code implements an NSProxy subclass which forwards methods to an NSNumber instance.
However when calling [nsproxy floatValue] I get 0.0 under GCC 4.2.
Under LLVM-Clang I get the correct answer 42.0.
Any idea what is going on?
(by the way this is running under Garbage Collection)
-(id) init;
{
_result = [NSNumber nu...
I'm still trying to find my way through memory management for the iPhone SDK, and I'm not sure why Instruments is reporting a certain block of code as a memory leak. I've followed tutorials for these parts of the code, so I'm not really sure what I'm doing wrong.
The violating block of code:
DreamTableCell *cell = (DreamTableCell *)[ta...
Hi guys - another weird problem with the iPhone SDK here.
I have a UITableView which contains a custom UITableViewCell. This table gets its data from a mutable array, which in turn pulls it from a Core Data storage.
The problem: If I enter editing mode and delete a cell, it works for the first time - the cell is successfully removed fr...
Folks,
I've got a bit of a puzzler involving Core Data in my iPhone project. During the viewDidLoad method in two separate view controller instances I call the following method:
- (NSFetchedResultsController *)getStudentResults:(NSString *)classRoom forWeekStarting:(NSDate *)startDate andEnding:(NSDate *)endDate {
AttendanceAppDel...
I have a SQLite database tied to my uitableview. There are about 2000 rows, so I retrieve 25 rows at first. Once I scroll to the end of the list, I want it to automatically retrieve 25 more rows.
Here's the method I'm using now. Ignore what would happen if I load all 2000 rows, I'll worry about that later. In tableView:numberOfRowsInSe...
I am planning to convert a rather long shell script I have into an Objective C command line tool. I'm planning to use NSTask to run the shell commands (this is a large script, and it has several thousand copy/move/delete operations). My question is, will continually allocating and deallocating NSTask objects to run all these commands res...
Does anyone know of a library to read/write the Xcode project files .xcodeproj/.pbxproj? Any language is welcome.
Thanks in advance.
...
Hi,
In iPhone SDK 3.0, I would like to register for a notification, which would alert my application when a certain time is reached. Is it possible?
Thanks
...