I heard that calling a handler (delegate, etc.) in Objective-C can be even faster than calling a virtual function in C++. Is it really correct? If so, how can that be?
AFAIK, virtual functions are not that slow to call. At least, this is my understanding of what happens when a virtual function is called:
Obtain the pointer to vtbl.
De...
initWithData does not convert my data object into a string properly. When I check the length of the data object, it has a value.
NSMutableData* receivedData =[[NSMutableData data] retain];
NSString* json_string = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
Am I doing something wrong creating the st...
This is the code I'm using to call the people picker, but the prompt label text doesn't change:
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
picker.displayedProperties = [NSArray arrayWithObjects: [NSNumber numberWithInt:kABPersonEmailProperty], nil];...
Hello, guys.
How to get/set the hours and minutes via code from a UIDatePicker in UIDatePickerModeCountDownTimer mode?
The situation:
I have an interface in that a user selects just hours and minutes. Then, he saves the information (so, I have to get the hours and minutes from UIDatePicker via code to save in a DB).
When the user is ...
I have a program for the iPhone that is supposed to be doing intelligent things (picking out appropriate icons for file types) given a list of filenames. I'm looking for the iPhone take on something like /etc/mime.types or something similar- an API call is what I'm assuming would be available for the phone. Does this exist?
...
Running instruments on the device, I intermittently incur a memory leak of exactly 3.5 KB in CFNetwork, the responsible frame being "HostLookup_Master::HostLookup...."
I have read a number of questions re this issue and have separately tried the following to fix the leak:
Included the following in applicationDidFinishLaunching:
NSURL...
This is really a few questions in one, I'm wondering what the performance cost is for these things, as I haven't really been following a best practice of any sort for these. The answers may also be useful to other readers, if somebody knows these.
(1) If I need the core data managed object context, is it bad to use
#import "myAppDeleg...
I want to know the width of an NSString displayed on the screen in pixels. So I can fit an NSTextField its bounds to be exactly the length of the string itself. So I used IB's "Label" NSTextField and for those who don't know what I mean, I got a label with title "Label", font "Lucida Grande 13px", not selectable, not editable, regular si...
Hi, i usually develop for iPhone. But now trying to make a pong game in Cocoa desktop application. Working out pretty well, but i can't find a way to capture key events.
Here's my code:
#import "PongAppDelegate.h"
#define GameStateRunning 1
#define GameStatePause 2
#define BallSpeedX 10
#define BallSpeedY 15
@implementation PongAppD...
Hey,
My head is about to explode with this logic, can anyone help?
Class A #imports Class B.
Class A calls Method A in Class B.
This works great
Class B wants to send a response back to Class A from another method that is called from Method A. If you #import Class A from Class B, it is in effect an infinite loop and the whole thing cr...
What's the best way to customize the Table Items to include two images. I'd like to set one as a background with another layered above it along with text.
Any help is much appreciated.
...
With CLLocationManager I can use the following code to determine if I can access location services on the device. This is the master setting for all apps and can be turned on and off.
if (self.locationManager.locationServicesEnabled) {
[self.locationManager startUpdatingLocation];
}
But a user can deny access to an individual app ...
I have a class called ModelView which inherits from NSOpenGLView.
When my program runs i attach the ModelView as follows to the main window.
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
ModelView *glView;
NSRect glViewRect = CGRectMake(0.0f, 0.0...
How would I get the last occurrence of an NSString within another NSString? For example, in "abc def ghi abc def ghi," I want to find the index of the second "abc," not the first. I know I could do this with a bunch of rangeOfStrings, but is there already a function for that?
...
I know the quick and dirty way of dividing by 60 to get minute, hours, etc
But is there an official way in the API already implemented, and using the appropriate language for minutes, seconds, etc?
Thanks for any help.
...
I keep getting 'warning: control reaches end of non-void function' with this code:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section ==0)
{
return [comparativeList count];
}
if (section==1)
{
return [generalList count];
}
if (section==2)
{
return [contactList count...
One of the crash reporter frameworks I've found does it like this: If there exist crash reports in the ~/Library/Logs/CrashReporter folder for the app, it determines that a crash occurred before. Then it allows the user to send the developer the crash log. And the finally, it deletes those logs.
It is this deletion that is bothering me....
See title. To be more specific, I am trying to return the mutableCopy of an object, however it's returned with a retainCount of 1 and I am worrying that it will leak.
...
When I select a cell in section 0 of my tableview I always get taken to section 1 first ?
I think its somthing to do with my 'if' statments
code : http://pastie.org/868523
Thanks in advance.
...
I've got an team (eveningRoster) that I'm making a button add employees to.
The team is really a relationship to that night's event, but it's represented with an AC.
I wanted to make sure an employee did not belong to the team before it adds, so I added a method to MyDocument to check first. It seems to work, the error logs complete, b...