So here's what I've got:
An NSTableView with an NSMutableArray data source
FSEvents monitoring a folder that contains the file that contains the data for the table view (Using SCEvents for Objective-C abstraction goodness)
The FSEvents triggers the same function that a reload button in the UI does. This function refreshes the table vi...
There's a lot of conflicting information about this topic. So let's try to agree on a definitive answer:
Which one of these random number generator in C create better randomness: rand, random or arc4random?
note: Just to make the question clear, this is not a question about true randomness, it's only a clash between those 3.
As poin...
When compiling this:
char *str = [[NSString stringWithFormat:@"%i days and %i hours", days, hours] UTF8String];
I get this warning:
initialization discards qualifiers from pointer target type
How do I get rid of it?
...
When creating a string using the following notation:
NSString *foo = @"Bar";
Does one need to release foo? Or is foo autoreleased in this case?
...
I have an animation which moves some views around. When this animation completes I want the window to recalculate the keyview loop. My code is simmilar to the follow mock code:
[NSAnimationContext beginGrouping];
[newView setAlpha: 0.0]; //hide newView
[self addSubView:newView];
//position the views
[[oldView animator] setFrame...
I'm creating a KVC/KVO-compliant mutable array on one of my objects the recommended way:
@interface Factory {
NSMutableArray *widgets;
}
- (NSArray *)widgets;
- (void)insertObject:(id)obj inWidgetsAtIndex:(NSUInteger)idx;
- (void)removeObjectFromWidgetsAtIndex:(NSUInteger)idx;
@end
Clearly this is a tricky thread-safety issue. In ...
After getting the objectEnumerator in the following code, the set1 retain count goes to 3. I was surprised to see that because I didn't expect it to change. I searched the documentation and can't find where this effect is explained.
I assume the extra retains are probably set to autorelease by the Cocoa enumeration logic and won't reall...
I am looking for a full fledged data modeling tool. Some of the features I would like are support for multiple databases, forward/reverse engineering, logical/physical modeling etc.
Please suggest one entry per response.
...
Hey folks,
I have a ton of repeating code in my class that looks like the following:
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request
delegate:self];
The problem with asynchronous requests is when you have various requests going off, and you h...
I have an odd edge case right now in that a response code from an NSURLConnection delegate method:
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response;
Is triggered before the subsequent delegate method:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
My code...
I'm using a UITableView to show some data from an array. This array can be changed at any time by other threads. (I believe that whether the array is mutable, or just replaced entirely, doesn't make a difference.) Access to the array itself is threadsafe.
What's the proper way to ensure thread safety with regard to the tableview? I'm wo...
Hi everyone,
I'd appreciate some feedback on a particular approach I'm thinking of using. The scenario is below.
I have an object (lets call it MObject) that has a number of properties, say, x and y coordinates, height and width. The properties are named according to the KVC guidelines (MObject.x; MObject.height, etc). My next task, is...
I am a little confused as to the definition of classes as Models or Views in the Sketch example AppKit application (found at /Developer/Examples/AppKit/Sketch). The classes SKTRectangle, SKTCircle etc. are considered Model classes but they have drawing code.
I am under the impression that Models should be free of any view/drawing code....
I have a struct defined like follows as part of an object. I'm trying to encode this for use with NSCoder with the aim of saving as well as Undo/Redo functionality.
struct myCol {
float rd;
float grn;
float blu;
float alp;
} toolColor;
So, there are methods to encode e.g. -encodeBool:, -encodeFloat:, -encodeObject: etc...
How do I trigger a delay, let's say I want to call a method (once) in 3 seconds from now, and how do I cancel that call if I need to?
...
I set up a simple event handler as mentioned here, but it appears that the selector isn't called. I put the code in my AppDelegate class and wired up the delegate in IB. Tried putting in some NSLog()s and breakpoints in the selector I expect to be called, but none of it is hit. The URL scheme works inasmuch as it launches my app, but it ...
According to Cocoa Programming for Mac OS X, 3rd Edition, on page 202 (chapter 13):
You will be registering, reading, and
setting defaults in several classes in
your application. To make sure that
you always use the same name, you
should declare those strings in a
single file and then simply #import
that file into any fil...
I have a couple of lines of trivial code such as the following:
NSData *dataReply;
NSString *stringReply;
dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
stringReply = [[NSString alloc] initWithData:dataReply encoding:NSUTF8StringEncoding];
The problem here is, initWithData:encodi...
I'm a developer who builds mainly single page client side web applications where state in maintained on the client-side. Lately some of the applications have become very complex with very rich domain models on the client-side and increasingly complicated UI interactions.
As we've gone along we've implemented some very useful design patt...
Let's say I have a split view, and I want to fill half of it with a table view (a fairly common use case, I would think). Is there any way to tell the table view to size itself to fit the split view or do I really have to size it manually?
...