objective-c

NSString to ByteArray and back

I am implementing an interface, which specifies writeBytes() and readBytes() on a file. The data has to be transported as JSON. For readBytes I do the following: 1. NSFileHandle readDataofLength - to read from a file 2. NSString initWithData: encoding: - to specify a given encoding 3. NSString getBytes:buffer 4. put each buffer[i] into...

OS X Mac and writing a twain scanning application.

Can someone point me to the correct place to start development of a twain scanning appliation for the MAC osx. I have done some simple objective c development in the past, but nothing interfacing with a device. ...

Printing Off-screen PDFViews

I have a situation where I want to print a multi-page PDF. While I could use the PDFKit utility classes and/or quartz functions to get the information to manually write drawing/pagination code for a NSView subclass, I had thought that quicker alternative would be to create an off-screen PDFView and tell it to print itself. When I tried t...

Detect orientation change in a UIImagePickerController?

Hello there! Im trying to detect orientation changes in a UIImagePickerController (it inherits from UINavigationController : UIViewController : UIResponder : NSObject) and I tried override the method - (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation in UIViewController but no success... any tip...

Does mac 10.3.9 support libxml2?

Im using xpath in libxml2 for retrieving the xml data which is working fine in mac 10.6, The same code is not working for 10.3.9? So want to know if the libxml version in 10.3.9 support XPATH? ...

Sounds randomly interrupted when starting to play

I'm calling playSoundFromBundle from the code below to play sounds (aif files). I have a sound that does a single click and then a fading sound. Both sounds are in the same file. Sometimes I get two clicks and then the fade. Meaning, click, click...fade. A single click isn't what should play. I'm guessing the sound starts (click s...

system language and system locale of mac ?

Can you suggest me the API to get the system language and system locale of mac 10.3.9 version using cocoa? ...

How do I add multiple keys and values to an NSMutableDictionary without using an array?

I know you could add all the keys to an array and add it to one side of the dictionary but I'm curious how you can add or insert a value at a certain point in the dictionary. The way i have it now it I believe it just keeps overwriting the last entries to make room for the new one: NSMutableDictionary *bookmarks = [[NSMutableDictionary ...

Parse data returned from j.mp

Hi, I'm currently writing an iPhone application, that posts a long url to j.mp (bit.ly). It is fully working and posts the long url successfully. But when I want to copy the returned data into an UITextView, I just get some JSON Data. Now my question: How can I parse this data, so that I only have the shortened url? Could anyone help m...

iPhone - Problem with MKMapView instance

Hi, I've got a problem with a MKMapView, which is placed as a full-sized view in a UITabBarController at first position. Before the view will be shown, I add several annotations to the mapView. Everything just works fine. When I change the tab (so that the mapView is out of view) and switch back to the tab with the mapView, all annotat...

Objective-C property assignment returns the assigned value?

Say I have the following: @interface MyClass : NSObject { NSString* _foobar; } @property (nonatomic, retain) NSString* foobar; @end @implementation MyClass @dynamic foobar; - (void) setFoobar:(NSString*)fbSet; { [_foobar release]; _foobar = [fbSet retain]; } - (NSString*) foobar; { return _foobar; } @end Then: MyClass* mcInst = [[[M...

Why is EXC_BAD_ACCESS so unhelpful?

First let me say I come from a background in Flash/AS3, which I realize is not as strict about most things as iPhone/Objective-C. I suspect my question actually applies to AS3 as well, but let me ask it as pertaining to Obj-c. Why is the error EXC_BAD_ACCESS, and others like it, so unhelpful? I realize that it normally means mismanageme...

IKImageView and scroll bars

I'm trying to use the IKImageViewDemo provided by apple (http://developer.apple.com/mac/library/samplecode/IKImageViewDemo/index.html) and I'm trying to add scrollbars to it. I've tried two things: 1) embedding the IKImageView in a ScrollView. This had all sorts of weird effects, like the image was no longer located where it should have...

xCode Release configuration behaves different.

I'm making a iPhone app written in Objective-C using the Cocos2d game engine. I'm using xCode v3.2.1 with the 3.1.2 iPhone OS. At this point I have always ran my project under Debug Configuration. When I set it to release configuration certain elements of my game are no longer behaving correctly. My logic that worked in the debug configu...

Can't initialize an NSMutableData with an NSData (which contains a png)

Hello, there is a error in my iPhone app. I use the CameraPicker to make and get a picture and then I give it to my methode sendPhoto, which will send the photo to TweetPhoto. Everything works great until I initialize an NSMutableDate with NSData. Here is the code: - (void)imagePickerController:(UIImagePickerController *)picker didFinis...

Does Objective-C use short-circuit evaluation?

I tried something along the lines of: if(myString != nil && myString.length) { ... } And got: -[NSNull length]: unrecognized selector sent to instance Does Objective-C not short-circuit after the first condition fails? ...

Objective-C memory not being freed with large arrays...

Hello all, I am developing a program in Cocoa, with the hopes of using the smallest amount of memory possible. To check this, I have been using Activity Monitor. My program has a fairly large NSMutableArray containing instances of NSString, and when I release the array, I do not get all of my memory back. The following example demon...

Pre-render UITabBarController views?

I have an app with a UITabBarController that manages some UINavigationControllers, which in turn manage various UIViewControllers. On 3G phones, the first time I view any particular view via a TabBar button, it's laggy, but thereafter, it's snappy. This isn't noticeable with 3GS phones. My question is how can I force these views to pre...

How to refer to the calling class in Objective-C

Can you refer to the sender of a message without passing the sender as a parameter? This is simplified code for the sake of discussion: // mainTableViewController.m [dataModel loadData]; //Table is requesting data based on user input // dataModel.m -(void) loadData{ // I want to store the sender for later reference se...

How to set NSToggleButton to start in state 0 from Interface Builder?

How can I in Interface Builder set NSButton of type toggle with Title and Alt.Title to start with the Title (e.g. the state 0)? The moment I set the button as toggle and set the Alt.Title it displays Alt.Title in View and I can't find the option to set it to start in the 'default' state (state 0). I could set it pragmatically but is th...