I have a CoreData entity (waypoint) with a foreign key to another entity (track). When the foreign key is set, or if it is not set, this if statement works fine:
if ([wp track]) {
thirdLabel.text = [NSString stringWithFormat:@"Part of Track: %@", [[wp track] title]];
}
However, if the track that the waypoint is keyed to has been del...
I'm trying to lerp between two CGPoints to get the values of all the pixels in between. I'm trying to find a simpler solution since right now I have a confusing recursive mess.
The problem is that lerping between two points produces a point in between the two. Now I have two groups of points to lerp through...
There has to be an easier...
How do we go about coding drag-and-drop (or tap-and-drag) from a cell in a TableView on an iPhone? I'd like to have a set of drop destination icons that are stationary. I've been trying touchesBegan, touchesMoved and touchedEnded methods. These events fire nicely from a View so I can get a swipe to work nicely. Most likely the destinatio...
Hello!
I recently received an Arabic translation for my app, but would like to do more than simply replace the strings. I can re-layout most of the NIBs with Interface builder, but there are a few things that I need to do programmatically.
Is there some way in Cocoa to figure out if the current locale is a RightToLeft locale, or do I...
I'm trying to set the shadow colour on a UIButton, but all I seem to be able to get is a mid grey.
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(20, 20, 200, 100);
[button setTitle:@"a" forState:UIControlStateNormal];
[button addTarget:self
action:@selector(buttonPressed:)
for...
I have set my iPhone in the landscape mode but when I try to display the UIAlertView its come in the portrait mode. How it will display in landscape mode?
...
Hi,
I'm having a hard time working with arrays. Coming from AS2/AS3 and garbage collection is new to me ... ;)
This is not the full code, just the parts that matter.
.h-file
@interface HelperViewController : UIViewController {
NSMutableArray *pagesNumbers;
}
@property (nonatomic, retain) NSMutableArray *pagesNumbers;
.m-file
@syn...
I am working with an API where I get a response back this this, and I want to parse the integer ID out of it:
<?xml version="1.0"?>
<trip>328925</trip>
How would you parse this? I have some really fragile code I want to get rid of, and I'd appreciate some advice:
if ([[response substringWithRange:NSMakeRange(0, 21)]
isEqualToStr...
for example we use this method in the tableview
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 16;
}
i want to learn we don't call this method in anywhere but application reads this value how is it being? there are a lot of methods like this we did not call.
...
I know how to use NSPredicate with relationships but for some reason when I do the same thing with a fetched property I get:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath address.id not found...' where address is a fetched property.
The code is like this:
[NSPredicate predicateWithFormat:@"...
How do I put a "hook" on an object so I can see what messages are being sent to it? (ie do an NSLog() every time a message is sent to an object).
I think recall seeing this done before but I forget how. I am thinking it might help me track down why part of my code is not working.
...
Is there a way to make a keyboard disappear without resignFirstResponder? I have a UITextField, and I'd like it to be able to accept new text and still have the insertion point (flashing cursor) visible without the keyboard being on screen.
When I perform a [textField resignFirstResponder] I can still insert text, by appending to the t...
Hi, i've been reading for a while a little bit of Objective C and Cocoa, and i have to say that although i am thrilled with the overall simplicity of Objective-C, I feel totaly lost regarding Cocoa and especially the MVC design pattern. The Cocoa books I've read, ask the reader to just complete a set of steps for a program to work, with...
If the class is a custom class, after posting the notification, the selector corresponding to the observer is called twice.. Is there any better solution so that the selector is called only once?
...
Hello Stacked-Experts!
My question: How to generate a string from a CLLocationDegrees value?
Failed attempts:
1. NSLog(@"Value: %f", currentLocation.coordinate.latitude); //Tried with all NSLog specifiers.
2. NSNumber *tmp = [[NSNumber alloc] initWithDouble:currentLocation.coordinate.latitude];
3. NSString *tmp = [[NSString alloc] ini...
When working on complex problems, I find myself trying all sorts of solutions and, while doing my best to stay organized, the code can get quite messy. Objects may be changed and no longer be of use, while other times I may add snippets of code that do not end up being used by the program but are taking up space and possibly memory.
Asi...
I seem to be having a problem with the titles in my application.
Let me describe what is happening here.
1) starts out good with the correct image
http://img262.imageshack.us/img262/5808/picture15b.png
2) still good after clicking a cell
http://img31.imageshack.us/img31/4440/picture13dvg.png
3) after hitting the backbutton previo...
Hi,
[Note: The title may be less than accurate, I didn't know how else to phrase it]
For some reason NSFileHandle's readInBackground didn't work so I resorted to SCEvents, a Cocoa wrapper around Mac OS X's FSEvents API. I have a separate class called "EventListener" that handles all the SCEvents stuff.
It has these methods:
- (void)se...
I have recursed a folder on a single volume, and retrieved a list of filenames, reference-counts and inode numbers, using
NSFileManager attributesOfItemAtPath
and NSDictionary fileSystemFileNumber and objectForKey:NSFileReferenceCount
For some reason I am getting results such as a reference count of 10, but a list of many more than 10...
Did I say "array" enough for you there? To clarify:
I'm working on organizing and array in an iPhone project.
I have an array of arrays. Each sub array has a list of items.
How can I make a new array of all the items contained in the sub arrays?
I've experimented with the addObjectsFromArray function with little luck.
Thanks!
...