objective-c

assignment of property and allocation leads to retain count of 2

Hi, I had a look at instruments and I saw that the alloc increased the retain count by 1. So far everything clear. But the assignment of the class to my property also increased the retain count to 2. self.myProperty = [[MyClass alloc] init] Vs. MyClass *myCreatedVariable = [[MyClass alloc] init]; self.myProperty = myCreatedVariable ...

MFMailComposeViewController send the email!

hello all, So I am trying to send an in application email on the iPad using the MFMailComposeViewController. However, everything I am reading shows how to set it up and get it ready, but not how to actually send it! I have the delegate all set up and handling the button clicks, but am not sure how to say "Now go send the email". Can...

NSCFString countByEnumeratingWithState:objects:count: ERROR while searching NSMuttableArray

Hy Everybody, i have the following situation. I have an NSMuttableArray filled with an xml file which I want to search. When I enter something in the searchfield I get this Error: "-[NSCFString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x5b388b0" What does it means and how can I fix it?!? I s...

iOS Bluetooth Keyboard Detection at Runtime

Is there any way in iOS SDK to detect the presence of an active Bluetooth keyboard? As many well know, when a Bluetooth keyboard is active, the on-screen keyboard does not show, so interface placements might have to change... Right now I am doing this semi-passively by responding to keyboard events, but those notifications are a little ...

Cocoa-Touch: UIWindow not rotating some subviews

I have an iPad app that is set to start in landscape mode. From what I read, the UIWindow itself doesn't need to be rotated, instead it will apply a rotation transform to all of it's subviews when the device is rotated. My application has a UINavigationController which has the app's views, and above it a custom MenuBarViewController wh...

How to port an app from old iPhone to iPhone 4? (Retina Display)

Hello world! Sorry if im asking something stupid but please dont shoot me down! I have done a little playing in xcode but nothing more than a button press counter kindof thing.. I was curious.. when developing with the retina display in mind you obviously produce higher resolutions png's and what not for the new display.. How would y...

Present a default view instead of tableview if datasource is empty

Hi everyone, The iOS app I'm currently working on is tabbar-based, and one of the tab is a UITableViewController. The thing is, when I open this tab with an empty datasource (for whatever reason), I'd like to bring another view, with some kind of message/image, instead of the blank view I get with the tableviewcontroller. I tried some...

Cocos2D game element design

Hey Guys, My question is as easy as that: What is the best method to create character for example in Cocos2D? Here's an example: I want to create an enemy of my "Ninja". The enemy has a strength of 0.5 and a speed of 50. How would you implement this? A subclass of CCSprite or CCLayer or something completely different? I tried with...

iPad Video with Transparency

Hi, is it possible to have a QuickTime video with alpha layer (transparency) play on top of a static dynamic background UIView (i.e. a view that changes occasionally) on the iPad? Thanks! ...

iphone: message sent to deallocated instance

Hi guys, i got a problem, if I run this code: NSString *xml = [[NSString alloc] init]; xml=[NSString stringWithFormat:@"<%@>", @"msg"]; NSLog(@"%@\n",xml); [xml release]; I got: 2010-09-07 11:45:15.523 test[1312:207] <msg> 2010-09-07 11:45:15.527 test[1312:207] *** -[CFString release]: message sent to deallocated instance 0x3d52ba...

How do I only update specific columns in an NSTableView

Hi, I have an NSTableView, with two columns. Whenever I add data to the table, both columns display the same data. How do I only update a specific column? I'm doing Mac Dev btw. This is the code I'm using: - (id)tableView:(NSTableView *)streamView objectValueForTableColumn:(NSTableColumn *)messageCol row:(int)row { return [[str...

Why would you drain an autorelease pool instead of releasing it?

Why would you drain an autorelease pool instead of releasing it? ...

What is a “weak framework reference”?

What does it mean to have a weak reference to a framework in iphone sdk? ...

Objectiv-C: Height of CGRect?

Hello together, I want to get the height of a CGRect-rectangle. I have a simple problem in understanding why these lines return 0 height: CGRect lalaframe = CGRectMake(10, 30, 45, 50); NSLog(@"_height of test frame = %d",lalaframe.size.height); Should be an easy fix... Thanks! ...

Objective C create object by class

I would like to know how to create an object of the specified Class in objective c. Is there some method I am missing in the runtime docs? If so what is it? I would like to be able to do something like the following: NSDictionary *types; -(id<AProtocol>) createInstance:(NSString *) name { if ((Class cls = [types objectForKey:name])...

UINavigationController Toolbar : problem setting UIBarButtonItems

-(void)viewWillAppear:(BOOL)animated { //setup toolbar [self.navigationController setToolbarHidden:NO]; self.navigationController.toolbar.barStyle = UIBarStyleBlackTranslucent; self.navigationController.toolbar.alpha = .8; self.navigationController.toolbar.tintColor = [UIColor colorWithRed:6.0/255.0 green:95.0/255.0 blue:163.0/255....

Reading a text field and comparing to an array object ?

Hi all, I have setup an array full of words as objects. I am trying then trying to compare what the user enters in a uitextfield to an object in the array to see if they match. I have captured a pointer to the uitextview in one of the delegate methods, however I cannot compare the text field contents to the object in the array. I assu...

Memory Warnings from images cause app to crash

I'm implementing the lazy table images algorithm similar to how facebook does. I got this from an example given by apple: http://developer.apple.com/iphone/library/samplecode/LazyTableImages/Introduction/Intro.html It works fine up until I start getting memory warnings. My images are stored in a dictionary, that links up a key to an ima...

how do i swap two NSString variables (in a non garbage collected environment)?

Hi everyone, I'm trying to swap two strings but I'm not sure if what I am doing is legal (coming from java I'm new to the whole retain count memory management). Here's my code: NSString *temp = [[NSString alloc] init]; temp = originalLanguageCode; originalLanguageCode = translatedLanguageCode; translatedLanguageCode = temp; [temp rele...

Regarding the copying of objects

Possible Duplicate: Why does C++ support memberwise assignment of arrays within structs, but not generally? Why is it that we can assign the object of one structure to other directly eg: struct student s1,s2; s2=s1 //is perfectly ok. but we can not assign one array value to the other eg: int a[10],b[10]; a=b //is not all...