First, I'm not sure I really understand what a selector is. From my understanding, it's a name of a method, and you can assign it to a class of type 'SEL' and then run methods such as respondToSelector to see if the receiver implements that method. Can someone offer up a better explanation?
Secondly, to this point, I have the follow...
Hi, I have the following object:
@interface SomeObject : NSObject
{
NSString *title;
}
@property (copy) NSString *title;
@end
And I have another object:
@interface AnotherObject : NSObject{
NSString *title;
}
@property (copy) NSString *title;
- (AnotherObject*)init;
- (void)dealloc;
- (void) in...
I can't seem to get my app to compile when using JSON-framework http://code.google.com/p/json-framework/ with iPhone SDK 3.0.
My app compiles fine for the simulator, but when I go to compile for my device I get a 'codesign error' code 1. I've followed all of the installation instructions correctly, and when I remove the 'Additional SDK'...
How does inheritance of NSNotificationCenter observers work? I have a parent class that several other classes end up subclassing. The parent class registers itself as an observer for a specific notification. I was under the impression that children would also be registered as observers as long as you invoke the super method where the reg...
Hi. This is the blurb accompanying the Audio Services function AudioServicesSetProperty. Its a bit over my head. Can someone give me an example of how to actually use this. Thanks.
AudioServicesSetProperty Sets the
value for a specified System Sound
Services property.
OSStatus AudioServicesSetProperty (
AudioServicesProper...
Hi,
I'm getting sublayers of a CALayer with this property accessor:
// @property(copy) NSArray *sublayers
NSArray* layer = mylayer.layer.sublayers;
Since this property uses "copy", every time I simply execute:
mylayer.layer.sublayers
is an entire copy of the sublayers array being made for me? If so that might be bad, because I co...
Hi, I want to have a percentage sign in my string after a digit. Something like this: 75%.
How can I have this done? I tried:
[NSString stringWithFormat:@"%d\%", someDigit];
But it didn't work for me.
Thank you in advance.
...
I have a daemon running on a server that's latched onto a TCP/IP port. I'm looking to see if there's currently any support iPhone/Cocoa-touch frameworks that gives a nice OO wrapper for speaking to the daemon over an IP socket. I need to be able to interactively query the daemon with commands and retrieve back information.
If there isn'...
Hi,
I have the following statement:
SELECT title, price FROM table WHERE id=?
Should I use to bind ID:
sqlite3_bind_int(myStmt, 0, current_id);
or do I have to use:
sqlite3_bind_int(myStmt, 1, current_id);
My question is - what should be the first binding parameter - 0 or 1?
The same question about getting data with sqlite3_col...
I have an objective-c class whose methods I only ever want to be called from the main thread.
I could achieve this by adding something like this to each selector:
- (void) exampleSelector: (id) param {
if (![NSThread isMainThread]) {
[self peformSelectorOnMainThread:@selector(exampleSelector:) withObject:param waitUntilDone...
I'm trying to draw a pill type ellipse, as in Apple's Mail application which displays the number of emails in the inbox. Any idea why the following isn't drawing?
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGFloat minX = CGRectGetMinX(rect);
CGFloat minY = CGRectGetMinY(rect);
CGFloat ...
I'm looking to write a sample application speaking to a POP3/SMTP server. Instead of re-inventing the wheel with BSD sockets and CFNetwork type calls, I'm curious if there is currently any open source libraries that already take care of alot of the dirty work? I've tried Googling without much luck for anything.
Perhaps there's something...
I want to make an iPhone app, but I am planning to make the framework in C++. Is it possible to use things like templates in Objective-C++. I guess really the question is, can I use boost?
...
I have a simple protocol with a property:
@protocol StopsSource <NSObject>
@property (retain,readonly) NSArray * stops;
@end
I'm adding a key-value observer elsewhere to listen to changes to the "stops" property:
id<StopsSource> source = ...
[source addObserver:self
forKeyPath:@"stops"
options:NSKeyValueObserving...
I am using NSURLConnection in an iPhone app as so:
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest: request delegate: self];
The request has been setup and works properly, but I want to be able to provide a "connection not available" message to the user if there isn't a connection available. Is there a quick way to d...
I have quite a few controls scattered throughout many table cells in my table, and I was wondering if there's an easier way to dismiss the keyboard without having to loop through all my controls and resigning them all as the first responder. I guess the question is.. How would I get the current first responder to the keyboard?
...
I have declared a delegate for my cocoa application here :
MyAppDelegate.h
@interface MyAppDelegate : NSApplication {
}
- (void) applicationDidFinishLaunching:(NSNotification*) notice ;
@end
MyAppDelegate.m
@implementation MyAppDelegate
- (void) applicationDidFinishLaunching:(NSNotification*) notice {
NSLog(@"inside appdidfinis...
I have a mutable array with contents I want to replace with NSNull objects.
This is what I do:
NSMutableArray* nulls = [NSMutableArray array];
for (NSInteger i = 0; i < myIndexes.count; i++)
[nulls addObject:[NSNull null]];
[stageMap replaceObjectsAtIndexes:myIndexes withObjects:nulls];
How can I do this more efficiently?
Is the...
Consider the following Cocoa/Obj-C code snippets:
MyClass *obj;
@try {
[obj doSomething];
}
@catch (NSException * e) {
NSLog(@"Exception occurred: %@", [e description]);
}
@finally {
[obj cleanUp];
}
and
MyClass *obj;
@try {
[obj doSomething];
}
@catch (NSException * e) {
NSLog(@"Exception occurred: %@", [e description]);
}
[obj...
I need to get time that elapsed between two events: for example between appearance of UIView and between user's first reaction.
...