I'm currently using the following code to fetch the logical NSView position of glyphs which is working fine however it seems a bit slow and the positions aren't precisely on the character kerning point and baseline. It very well may be the case that all I need to do is iterate the glyphs themselves one by one and build the rect myself.
...
I'd like to get the first three digits from large floats or integers and on some insert a decimal. For example:
KB
----------
32589 >> 325
43266 >> 432
MB
----------
1234599 >> 1.23
3422847 >> 3.42
For the particular number, I will have the "KB" and "MB" strings. This will let me know if the decimal is required, as in "MB" examples...
Hi everyone,
I'm using a custom drawn UITableViewCell, including the same for the cell's accessoryView. My setup for the accessoryView happens by the way of something like this:
UIImage *accessoryImage = [UIImage imageNamed:@"accessoryDisclosure.png"];
UIImageView *accImageView = [[UIImageView alloc] initWithImage:accessoryImage];
accI...
Do I need to release a Core Foundation objects to clear up memory? And if so, how?
For example, in the code:
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef peopleArray = ABAddressBookCopyArrayOfAllPeople(addressBook);
do I need to release peopleArray? What about addressBook?
...
Why is my table view blank? It was fine until I added "initWithStyle"
Here is what it looks like:
And here is what my code looks like:
Here is my .h:
#import <UIKit/UIKit.h>
@interface TableViewController : UITableViewController {
NSMutableArray *jokes;
IBOutlet UITableView *jokeTableView;
}
@property (nonatomic, retain) NSM...
I would like to send an object back to the main thread from worker thread. However do auto-release pools work between threads? Is there anything wrong with the following code:
-(void)mainThreadReceiveResult:(id)response
{
[response retain];
/* Do some stuff with response */
[response release];
}
-(void)workerThreadDoWork
{
N...
The -description method for NSArray will nest recursive calls as in:
2009-05-15 14:28:09.998 TestGUIProject[29695:813] (
a, // Array1 item 1
( // Array2, a second array, nicely indented another 4 spaces
a // Item in Array2
) // End of Array2
) // End of Array1
I want to do something similar for my own custom cl...
I have 5 cells in a tableview that are all custom. Meaning, I've created a xib with a tableviewcell and created a corresponding cellController. The xib has two labels named name and size. The user taps a row, triggering didSelectRowAtIndexPath. From there a timer is started. At some point the timer finishes. Here I need to assign te...
Hey there, quick question here. I'm sure there's a simple answer.
Coming from PHP, I'm used to declaring a function with a default argument value like this:
function myFunction ($array, $sort = FALSE) {
}
I the sort parameter wasn't filled, the function would continue with the default value of false. In Obj-C, is there a similar t...
I'm due to work on a small application that captures audio from the Mac's Audio Queue and needs to save it to disk in some reasonable audio format.
Does anyone have a some decent sample code (Cocoa / Objective-C) that they can share?
I specifically need to capture the audio that is being passed to the Built-in Output device in order ...
Hello experts!
I recently found a good tutorial about how to place a navigation controller within a tabbarcontroller("The nib way").
http://twilloapp.blogspot.com/2009/05/how-to-embed-navigation-controller.html
I continued with the second step and added a tableviewcontroller to the navcontroller.
What I don't understand, is how I can...
Which is right? This:
NSArray* foo = [[NSArray alloc] initWithObjects:@"a", @"b", nil];
[bar performSelectorInBackground:@selector(baz:) withObject:foo];
- (void)baz:(NSArray*)foo {
...
[foo release];
}
Or:
NSArray* foo = [[[NSArray alloc] initWithObjects:@"a", @"b", nil] autorelease];
[bar performSelectorInBackground:@selec...
How would I rename a file, keeping the file in the same directory?
I have a string containing a full path to a file, and a string containing a the new filename (and no path), for example:
NSString *old_filepath = @"/Volumes/blah/myfilewithrubbishname.avi";
NSString *new_filename = @"My Correctly Named File.avi";
I know about NSFileMa...
While attempting my first sub-class in Objective-C I have come across the following warning which I cannot seem to resolve. The call to decimalNumberWithMantissa gives a warning of "initialization from distinct Objective-C type".
#import <Foundation/Foundation.h>
@interface NSDecimalNumberSub : NSDecimalNumber {
}
@end
@implementation...
The title says it all. I don't know Objective-C but to me it appears a nice language. But the only context I know it from is everything Apple. But Objective-C is even in the gnu compiler collection.
Is there something missing in the open ones? Or is there already a broader base for Objective-C? I'm interested if there are companies tha...
What are some best practices to keep in mind when working extensively with SQLite on the iPhone? Tips/tricks/convenience factors all appreciated.
...
Does anyone have an example of how to draw the blue "unread dot" used in Apple's Mail App? This one in specific: http://bit.ly/3A7XxD
Drawing an ellipse is straight forward with Quartz2d, but the subtle use of shadows+gradients make this look really 3d.
...
In short, [NSURL URLWithString:] appears to be raising an exception. According to the documentation "If the string was malformed, returns nil." There is no mention of an exception being raised under any circumstance. In addition to this, I am both encoding the URL and checking for nil before converting the string to a URL.
Can anyone of...
I'm working through Aaron Hillegass' book, specifically the lottery example. I had a question about the -setEntryDate: method; why do I have to retain date? The program still works without retaining it.
-(void)setEntryDate:(NSCalendarDate *)date {
[date retain];
[entryDate release];
entryDate = date;
}
But this still work...
Hi,
I have an objective-c class which contains a pointer to another class. I want to archive an instance of this class via NSCoder:
@interface Barn
{
int m_numHorses;
// Barn does not allocate this instance, it just points to it.
Farmer* m_pFarmer;
}
@end
...
- (void)encodeWithCoder:(NSCoder *)encoder
{
[encoder enco...