objective-c

How to change the height of table view cell

i m trying to read some RSS data. I have the data that is of different sizes. the data is present in tabke view data object. I used the label to add the data and resize the dat. No success. Please help. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIden...

How to make main window visible in Cocoa?

This is kind of a followup to this question. I have the following code: - (BOOL)applicationShouldHandleReopen:(NSApplication *)app hasVisibleWindows:(BOOL)flag { NSLog(@"Has visible windows: %d, main window visible: %d", flag, [[app mainWindow] isVisible]); if (!flag) { // I need to make mainWindow visible again here. HO...

Making a thinner UITabBar

I would like to be able to thin the UITabBar's height by removing each item's titles and reclaiming the vertical space they take up, a la Tweetie 2. This doesn't seem settable in the .xib or programmatically. Will I have to subclass the UITabBar and roll my own? ...

Replacing a UIViewController root view with my own view

I'm trying to replace a UIViewController root view with a subclassed UIView. In the iPhone SDK's UIViewController Class Reference, within it's Overview section, this is stated: You use each instance of UIViewController to manage a full-screen view. For a simple view controller, this entails managing the view hierarchy responsible fo...

How to display iPhone free memory ? and how to free iPhone memory?

How to display iPhone free memory in a UILabel ? and I would like to ask, how to free up memory using iPhone SDK? FYI, I'm using iPhone SDK 3.1.2 with xcode 3.2.1 (Mac OS X Snow Leopard). ...

Show bounding box of UIImageView in UIView

I have written a class extending UIImageView in order to allow me dynamically generate bricks on screen. The brick is a 20x10 PNG. Here is my codes: - (id) initBrick:(NSInteger *)str x:(float)ptX y:(float)ptY { int brickIndex = arc4random() % 10 + 1; NSString *filename = [NSString stringWithFormat:@"brick%d.png", brickIndex]; UIImage ...

When to use nil and NULL in Objective C ?

This is a sample code: NSDictionary *myDictionary = [NSDictionary dictionary]; NSNumber *myNumber = [myDictionary valueForKey: @"MyNumber"]; NSLog(@"myNumber = %@", myNumber); // output myNumber = (null) if (myNumber == nil) NSLog(@"test 1 myNumber == nil"); if (myNumber == NULL) NSLog(@"test 2 myNumber == NULL"); if ([myN...

Removing an Observer.

In a NSManagedObject Sub Class I have the code … - (void) awakeFromInsert { [self addObserver:[NSApp delegate] forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil]; } Which adds my App Delegate as an Observer, what I want to do now is from inside my App Delegate, I want to remove itself as an Observer for my NSManag...

Converting a NSString to a cString for use with CGContextShowTextAtPoint

Hi, I am drawing a String using CGContextShowTextAtPoint. Thus I need to convert my NSString I want to draw into c Strings. Unfortunately special symbols like the euro currency symbol are not correctly shown. CGContextSelectFont(currentContext, "TrebuchetMS", 15, kCGEncodingMacRoman); CGContextShowTextAtPoint(currentContext, 0, 0, [my...

Collision Detection in iPhone SDK: Inaccurate CGRectIntersectsRect

When there are two objects going to collide, I check them with CGRectIntersectsRect. However, before it returns me with YES (they collide), they are already overlapped. Is there any other way to detect and resolve collision? My workaround is to compare their Y axis and move the object far apart from each other, once they are detected co...

how to save slidervalue and label value in nsuserdefaults or any other efficient way?

i have a view with one slider and a label.i am showing a countdown on label and setting time on label using slider.now suppose i have started the timer so the label's value is decreasing every minute and slider's value is also decreasing.now i want that if i close my app and then reopen the timer should be already running+label's value i...

Objective-C: instance variables out of scope in debugger

I have a superclass and a subclass, both of which define instance variables. Rough outline of superclass: /* GenericClass.h */ @interface GenericClass : NSObject { /* some variables */ } @end /* GenericClass.m */ @implementation GenericClass /* ... */ @end Outline of subclass: /* SpecificClass.h */ #import "GenericClass.h" ...

How to change the background color of any view dynamically?

hello all, How to change the background color of a view dynamically? Do I set a timer and assign the background color property of the view to change in a loop? How to achieve this functionality? ...

iPhone: finding the currently "highest" view

Hi! I'm coding a MobileSubstrate plugin (a code insertion platform on jailbroken devices) which will hook into safari and a few other apps. This plugin will have to display an UIActionSheet. But in order to do that I need to find a view to display it in. so far I'm using showInView:[[UIApplication sharedApplication] keyWindow] but it'...

how to stop core animation?

i am animating a button using core animation now on a certain condition i want to stop that animation how do i stop the animation? here is the method to animate the button -(void)animateButton:(UIButton *)btnName { CABasicAnimation *pulseAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; pulseAnimation.duration = ....

Works with number of string contained in NSArray

Hi, I need to pick string valur from an NSMutableArray then save it into a plist. I've builded an NSMutableArray to display infos in table View. Maximum allowed index is 8. (paste just two in example) The problem if the String doesn't exist, I get the following error: sDict is a dictionary for saving datas to a property list file. th...

is Open GL a Overkill for a 2d Card Game ?

Hi, I was just have an idea of creating a card game and I was just thinking whether to use OpenGl or CoreAnimation.Can you please tell me whether it would be a bit of a overkill to use OpenGL for s 2D card game.Thanks :) ...

Is leaking objects considered OK in Testing Scenarios?

I have written some Objective-C test cases. A typical looks the following: - (void) test_size_Equals_Excpectation_After_initWithSize { int size = 10; Buffer* buff = [[Buffer alloc] initWithSize:size]; GHAssertEquals([buff size], size, nil); } Buffer alloc returns buffer with reference count 1, I didn't care to call autore...

Initialize window code Mac OS X

I'm currently reading "the red book" for learning OpenGL properly, and in one of the first examples, the author writes a line that says "InitializeAWindowPlease();" as a place holder for the code that will make a window to draw the OpenGL content in. Since I'm using Xcode for my programing, I know that I "get" a window to work with aut...

How to declare a string in Objective-c?

How do I declare a simple string "test" to a variable? ...