cocoa

[Obj-C/Cocoa] NSURLConnection leak issues

As a disclaimer I'd like to state that I'm fairly new to Objective-C and Cocoa. Currently I'm trying to write a basic application that can POST XML data to a particular endpoint. To achieve this, I've created a ServiceRouter class which uses NSURLConnection to post XML data to a particular URL. The ServiceRouter class is intended as a ...

Retrieving a unique result set with Core Data

I have a core data based app that manages a bunch of entities. I'm looking to be able to do the following. I have an entity "SomeEntity" with the attributes: name, type, rank, foo1, foo2. Now, SomeEntity has several rows if when we're speaking strictly in SQL terms. What I'm trying to accomplish is to retrieve only available types, ev...

Reasons for NSManagedObjectMergeError error on [NSManagedObjectContext save:]

I have a application that combines threading and CoreData. I and using one global NSPersistentStoreCoordinator and a main NSManagedObjectContextModel. I have a process where I have to download 9 files simultaneously, so I created an object to handle the download (each individual download has its own object) and save it to the persisten...

NSDecimalNumber subtraction

Hello, I need to subtract 0.5 from number a and set the answer to number b. My code looks like it would work but I'm not sure what I'm doing wrong. The error I get Is on the subtraction line, the error says incompatible type for argument 1 of 'decimalNumberBySubtracting:'. Heres my header: (Note: I only showed the numbers because the h...

Copying blocks (ie: copying them to instance variables) in Objective-C

I'm trying to understand blocks. I get how to use them normally, when passed directly to a method. I'm interested now in taking a block, storing it (say) in an instance variable and calling it later. The blocks programming guide makes it sound like I can do this, by using Block_copy / retain to copy the block away, but when I try to run...

cc1obj: error: type '({anonymous})' does not have a known size , Xcode

huh? google returns nothing on what this error is... All I am doing is adding a movieplayercontroller to a flipside iphone app. cc1obj: error: type '({anonymous})' does not have a known size {standard input}:228:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_9" minus "L00000000004$pb" {standard input}:228:symbol: "...

NSNotification on multiple objects

Hi, In my NSApp delegate I add an observer of an object that is an NSWindow subclass that gets initiated in the delegate itself and that posts a notification once the window gets clicked. The selector is also in the delegate. From that same delegate class I initiate another object which when initiated adds itself as an observer for anot...

Retain information in cocoa?

Hello, I'm still new to Cocoa and don't know much about memory management. I read up on Apple's documentation but I'm still confused. My question is if I set the value of a variable in a - (void)dowhatever when dowhatever ends, will the contents of the variable be erased? If so is there a method (without writing to a file) that I can us...

Getting SHOUTcast metadata on the Mac

I'm creating an application in Objective-C and I need to get the metadata from a SHOUTcast stream. I tried this: NSURL *URL = [NSURL URLWithString:@"http://202.4.100.2:8000/"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL]; [request addValue:@"1" forHTTPHeaderField:@"icy-metadata"]; [request addValu...

What is the usage of NSResponder's indent:?

NSResponder has a method you override called - indent:, but unsure when it would normally be activated. ...

NSImage from website URL

Hello, I need to create an NSImage from a url and then set it to an image view in my application. I tried some code I found online but it didn't work. If anyone knows how to do this any help would be great. Thanks ...

Load NSImage from url but only some url's work

I have some code that loads an image file off the web and puts it in an image view. The problem is it works with everything except Google Charts. This is frustrating because I was relying on this to graph data for my app. Heres the url I need to load: Click to see my test chart. Im not sure why NSImage seems to refuse to load this when i...

What would cause objectForKey: to return null with a valid string in place?

I am having an issue with NSDictionary returning null for an NSString even though the string is in the dictionary. Here is the code: - (void)sourceDidChange:(NSNotification *)aNote { NSDictionary *aDict = [aNote userInfo]; DLog(@"%@", aDict); NSString *newSourceString = [aDict objectForKey:@"newSource"]; DLog(@"%@", newS...

Does the respondsToSelector method have to exist?

Does a method which I check for with respondsToSelector have to actually exist? What if I only define it in the interface part and fail to implement it? I'm looking at a poor-man's virtual function in Objective-C. ...

Popup NSColorPanel?

Hi, Is it possible to make an NSColorPanel 'Pop Up', almost like a popup menu, from the NSColorWell? I don't like how it's implemented as a palette, as it's sometimes not obvious which NSColorWell it's associated with. Thanks! MT ...

How to get the current eventNumber for creating an event with NSEvent

Hello I'm creating an os x application for which I try to add a remote interface. For this I need to be able to send mouse down and mouse up commands to the window of my application. I found code with which I can successfully do this, it looks as follows: int mask = 0x100; NSEvent* eventMouseDown = [NSEvent mouseEventWithType:NSLeftMou...

How does this "&" work in this statement?

I know how bitwise AND works,but I don't understand how does (sourceDragMask & NSDragOperationGeneric) work here,I don't get the point.Is there anyone can explain to me?Thanks a lot. - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender { NSPasteboard *pboard; NSDragOperation sourceDragMask; sourceDragMask = [send...

Monitor Network Traffic Mac

I'm wondering how to go about monitoring network traffic on my Mac. Like the way activity monitor does it, showing the bytes / packets in and out. I know it's a bit vague, but I'm unsure of the best place to start. EDIT: I forgot to mention, I'm wanting to do this in code, not use an existing piece of software. ...

Should I call release on these cocoa objective-c variables?

In the code below I'm making a new NSString with alloc and initializing it with the contents of some file. Because I'm calling alloc I know it's my responsibility to call release on the string when I'm done. But what about the variables "lines" and "line"? Since the method "componentsSeparatedByString" does not start with the word "ne...

Where are events in Cocoa Touch?

Hi all! I learn Cocoa Touch several days, and today have stuck while looking for way to implement a custom event. Event that I can see in Connection Inspector for my UIView subclass. What I have: There are a UILabel and MyView:UIView on MainVindow. MyView contains a UISlider. Interfaces for Controller and MyView // Controller.h @inter...