objective-c

Using Core Animation with objects other than CALayers

I was pretty sure I had seen discussions of this around the Net, but now I can't seem to find anything. The question is simple: is there a way to use for example CABasicAnimation to animate a property on an object that's not a ´CALayer´? (Say, the ´volume´ property on an ´AVAudioPlayer´.) If not, is there a way to make it work other tha...

Release in viewDidUnload and dealloc both?

I have been under the assumption for a while that viewDidUnload is always called when a controller is deallocated. Is this a correct assumption? I've just been exploring some odd things, and set a breakpoint in my controller's viewDidUnload and it's dealloc. It appears that dealloc is called, but the viewDidUnload method is never call...

Objective-C :: using a method to change an object

I have a class called "CardSet", containing an NSMutableArray* cardSet to hold "cards", which I extend to make "DeckCards". I'd like "CardSet" to have a method called "(void)addCard:(Card*)" (and similarly a method "removeCard"). I'd like "addCard" to some how have access to and set cardSet. Even better I'd like to use the "addCard" meth...

upload image in flickr from iphone

Hi All, I am developing a application where i want to load the image on flickr.I have seen the Snap and Run project where i tried to share the image using my API key but cannot do it. its giving response as invalid callback url. Can anyone help me with this as I am not able to do this,, Thanks in advance, ...

iPhone: adding button to scrollview makes button inaccessible to interaction

For some reason, the button initialized in the addBook method of my viewController won't respond to touches. The selector I've assigned to it never triggers, nor does the UIControlStateHighlighted image ever appear when tapping on the image. Is there something intercepting touches before they get to the UIButton, or is its interactivity...

How to mix Qt, C++ and Obj-C/Cocoa

Hi, I have a pure C++/Qt project on a Mac, but I now find that I need to call a few methods only available in the Cocoa API. Following instructions listed here: http://el-tramo.be/blog/mixing-cocoa-and-qt I have a C++ class implementation in a ".m" file. As a test, my "foo.m" file contains the following code (relevant #include methods...

How to convert NSNumber to NSInteger

How to convert an NSNumber to NSInteger ? ...

iPhone Developer's Cookbook: ModalAlert Frozen

I've used a recipe from the iPhone Developer's Cookbook called ModalAlert in order to get some text from a user; however, when the alert is shown, the keyboard and buttons are frozen. Here is the code for the modal alert. +(NSString *) textQueryWith: (NSString *)question prompt: (NSString *)prompt button1: (NSString *)button1 button2:(N...

UIButton setBackgroundImage consumes a lot of memory

I'm using the following code: UIImage *buttonImage; if (p.placeImage != nil) { buttonImage = [UIImage imageWithData:p.placeImage]; } else { buttonImage = [UIImage imageNamed:@"bg_place_noimg.png"]; } [imageButton setBackgroundImage:buttonImage forState:UIControlStateNormal]; When executing the app with Instruments I can see ...

Using GameKit to transfer CoreData data between iPhones.

I have an application where I would like to exchange information, managed via Core Data, between two iPhones. Has anyone attempted this and if so what is deemed to be the best approach to doing so (i.e. are people using some intermediate format such as XML or JSON in a file or can the objects be transfered directly). My apologies if t...

Is it possible to have "implementation-only" class members?

Hi, this is kind of a beginners question so please bear with me. I've got a class that makes use of a third-party library (oniguruma, if that matters). I want library methods to be completely decorated by my own, so that I can switch the underlying implementation of my class anytime. Something like: // MyClass.h @interface MyClass : N...

ivars and how to properly instantiate their values (iPhone)

Hi I have been developing an app for a while and now I have gotten to the "Instruments-Leaks" part. I remember a thing that puzzled me about ivars a few months back when I was learning. I took the whole thing a bit on faith and just followed the way Apple and others did it. As far as I can read, the accessors generated by the SDK will ...

How can I handle control resizing when rotating screen

Whilst 90% of my controls resize perfectly with the snapping features. I have some elements which are sized programmatically due to their contents (i.e a label and its container) in the ViewDidLoad function. Is there anyway to get a handle on the screen rotation event? So I can perform my control resizing manually? Thanks ...

Do I need release in the dealloc?

In the book I'm studying from for iPhone dev, they utilize IBOutlet instances using the Interface Builder. An example would be a UIButton. So they add a thing in the struct like this: IBOutlet UIButton *whateverButton; Then they add a @property for each of these in the .h, and a @synthesize in the .m. Then they include a release in ...

How to convert an NSArray of NSManagedObjects to NSData

Hi, I'm new to Objective C and was wondering if anyone can help me. I am using core data with a sqlite database to hold simple profile objects which have a name and a score attribute (both of which are of type NSString). What I want to do is fetch the profiles and store them in an NSData object, please see my code below: ...

Data loading systems for the iPhone

I’m trying to decide the best way to load data into my app, it’s basically a book, but I want to have control of the chapter line number and chapter name ( so I can add comments and notes under relevant lines) etc. Both options allow me to do this. There’s going to be about 25 large-ish chapters. What would be the best overall in term...

Check if valid url so i can pass it to an NSURL?

I want to check if an NSString is a valid URL so I can parse it to an NSURL variable... is there an easy way to do this? :) CRASH For some reason the app crashes when checking..... NSURL *shortURL = [[NSURL alloc] initWithString:data]; if(shortURL == nil) { NSLog(@"INVALID"); } else { NSLog(@"COOOL"); } The console gives me t...

Customize TableviewCell depending on section

Hi folks, How do I customize the background image of a tableViewCell depending on the section, they are in? E.g. in section one, the cells are supposed to have a green .png image as a background image, whereas in section two, the cells are supposed to have a red .png image as background. Thank you for your help! gstar ...

iPhone dev - Set position of a view in viewDidLoad

So, in Interface Builder I have a view within the superview that contains two Image View objects. I'd like to move that view off the screen when the app launches so it can be animated to move into place. The view is described as pictureFrame in the .h file for the interface, and I have the view mapped to the outlet pictureFrame. Here is ...

Multi-player server for iPhone application, using device as socket server.

I'm working on a multiplayer iPhone application that allows up to 6 users to connect and play in "real time." I've been looking at hosted and non-hosted socket servers (SmartFox, ElectroServer, Photon/Neutron, ProjectDarkstar) and I'm wondering if anyone has any recommendations for services or implementation? Anyone have any idea of what...