cocoa

How to figure out if the network the mac is connected to is a WiFi or cable network or the like...

Hi all, First off, you guys are all really helpful - thank you a lot! Is there a way to figure out what type of network a Mac is connected to? WiFi? Cable? USB Modem? Any Cocoa / Foundation framework I can use to figure that out? Thank you, Matthias ...

How to structure the code for a Cocoa Application

I'm writing a Cocoa application where I have an auto generated app delegate:(MyAppDelegate.h/MyAppDelegate.m) So I am not sure of the best way to structure the class files for this Cocoa application. I understand MVC thoroughly (on the iPhone) but I'm having a block as to try organising the source properly in a Cocoa app. I need to spa...

Memory problems with NSMutableDictionary, causing NSCFDictionary memory leaks

Hi! Help me please with the following problem: - (NSDictionary *)getGamesList { NSMutableDictionary *gamesDictionary = [[NSMutableDictionary dictionary] retain]; // I was trying to change this on the commented code below, but did have no effect // NSMutableDictionary *gamesDictionary = [[NSMutableDictionary alloc] init]; // [g...

Suggestion for dragster/dropzone like dock menu

I'd like to create a dragster/dropzone like dock menu. Looks a bit like a stack with a nsview in it. After a lot if documentation searching and googling I've found a way to determine a dock icon's location. (http://cocoadev.com/forums/comments.php?DiscussionID=1431) Is nzbdrop creating a view which just looks like an stack to display...

Changing GUI from a thread that's not the main thread?

My idea is to have a view that is showing the user when something is calculated behind the scenes. It is a view with a height of 30px containing an UIActivityIndicatorView and an UILabel showing what is beeing calculated right now. I tried to implement it by having a ActivityHandler with these methods: - (void)newActivityStarted{ [...

How can you get the touch location during scrollViewDidScroll

It seems that the UIScrollView stops sending touch events to the delegates on the scrollViewDidScroll event. I'm trying to get the y location and can't seem to find access to the events. I would like to update the view based on the position while it's scrolling. The best lead I've had has been this ( http://github.com/andreyvit/Scrolli...

iPhone - how to use performSelector with complex parameters?

I have an application designed for iPhone OS 2.x. At some point I have this code - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //... previous stuff initializing the cell and the identifier cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentif...

using JSON in cocoa

I'm using cocoa JSON framework http://code.google.com/p/json-framework/ Here is the result of an JSON output that I get. I can see that results in dictionary Response { "completed_in" = 0.02461; "max_id" = 10088639298; "next_page" = "?page=2&max_id=10088639298&q=apple"; page = 1; query = apple; "refresh_url" = "?since_id=10088639298&q=...

Cocoa's NSDictionary: why are keys copied?

All objects used as keys in NS(Mutable)Dictionaries must support the NSCopying protocol, and those objects are copied when they're used in the dictionary. I frequently want to use heavier weight objects as keys, simply to map one object to another. What I really mean when I do that is effectively: [dictionary setObject:someObject forKe...

NSLevelIndicator Not Updating

I've got an application with an NSLevelIndicator Object on it that's refusing to update. I have a timer that's shoved off during init and updates the value of the NSLevelIndicator using its setIntValue method. Whilst the code executes without any exceptions, the NSLevelIndicator never visually updates. I have some other labels on th...

Xcode Build Options, etc. Tutorial

I've worked on a few projects now, and I've had to change the framework search paths, set the bundle loader, etc. But I've never felt totally comfortable with that Project (or Target) "Get Info" window. I still don't know what half the stuff in there is, and whenever I change anything, there's always a bit of finger-crossing when I clic...

iPhone - Debugging EXC_BAD_ACCESS crashes

From times to times, while debugging an Application, I see this error on Xcode: Program received signal: “EXC_BAD_ACCESS”. and the debugger does not stop on the problematic line. In fact the debugger just shows me a page with a bunch assembly language code and that's it. I have to have paranormal powers to figure out where the exact ...

Detect when other process is shutdown OSX

I need a way to determine from a Cocoa app if a given process name is running. One idea I had was to use NSTask and poll using ps aux | grep processName. Is there a better solution? ...

misaligned_stack_error after moving some code into external framework (Cocoa)

I just moved a bunch of code into a separate framework. Nothing has changed in the code since the move and it compiles fine. However, on runtime, It crashes with "misaligned_stack_error". I've been looking around and some people are saying -mstackrealign fixes it, however I have added it to the C flags for both projects in Xcode and it s...

Make a disabled, formatted NSTextField update on a locale change?

I've got a couple of NSTextFields in my application for entering date and time. They have NSDateFormatters (using NSDateFormatterBehavior10_4) attached to them. When I change the system date format in System Preferences, then switch back to my application, the text fields automatically update with the new date format, but only if they ...

Accessing views from within NSTextField Category?

I've got several different classes in my code utilising identical methods -- resulting in a lot of duplicated lines -- and I recently found out about adding Categories which promises an effective solution to the problem. To give one of the smaller examples, my previous methods were (typically) called in the traditional way like this: if...

How to alter colors in mac/cocoa text views

Is there a way to alter the standard background and text colors in cocoa text views throughout the mac os? Since the same text system is used by textedit, mail and other programs, I imagine there is an underlying preference that could be altered. Any ideas how to access it? Just to be clear, I don't mean simply to alter the document col...

Is it valid to ignore an return value of an method in objective-c?

For example, when I call a method that returns an value, but I'm not interested in this at all, can I safely ignore that? Example, instead of: CGSize size = [str sizeWithFont:myFont minFontSize:19.0f actualFontSize:&actualFontSize forWidth:150.0f lineBreakMode:UILineBreakModeClip]; ...do this: [str sizeWithFont:myFont minFontSize:19...

In cocoa, how do you connect the model to viewcontrollers?

So from what I understand the basic application structure for cocoa programs is an AppController in MainMenu.xib. The AppController then initializes the WindowControllers and ViewControllers which has all the UI logic and in turn load the xib files for the rest of the application. The AppController also creates the Model classes. My co...

When should I extend NSDocument and when should I extend NSWindowController?

I've an application that holds a main window with a list of items, and from that window an undetermined number of windows can be opened. Each of those windows can hold several instances of a model object, with those instances listed in a drawer. I started my project by making the (main window) list of items extend NSDocument and each ot...