objective-c

Sane(r) way to get character-encoding of the CLI in Mac OS X?

Hi all! I was writing a CLI-Tool for Mac OS X (10.5+) that has to deal with command-line arguments which are very likely to contain non-ASCII characters. For further processing, I convert these arguments using +[NSString stringWithCString:encoding:]. My problem is, that I couldn't find good information on how to determine the characte...

How can I assign properties correctly?

I have a UITabBarController that I would like to assign to another object, so that that object can control it: watchListView.tabBarController = self.stTabBarController; During this assignment the value of both self.stTabBarController and watchListView.tabBarController are 0x0. How can I assign the UITabBarController's? ...

Code not executing as expected when loading URL into UIImageView

Im having trouble with my code, it seems that it never executes right. I've tried many things from UIActivity, Sliders, UITextVieweer etc... but it never changes, The code is running using Navigation based application from xCode. loadingTview is a Textview, The problem is, see where loadingTview is, that never works, it always hangs,...

Why a DataCallBack method listen in the background is not being invoked?

Hi, I've been working with CFNetwork to create a client application for iPad, it is a small application, nothing fancy. This is how I create the connection to the server (running in windows). - (void) startConnection { char ip[] = "192.168.0.244"; NSString *ipAddress = [[NSString alloc] initWithCString:ip]; /* Build our s...

How to switch tabs in UITabBarController?

I have a UITabBarController that is being presented modally from a RootViewController: stvTabBarController = [[UITabBarController alloc] init]; stvTabBarController.delegate = self; stvTabBarController.viewControllers = [NSArray arrayWithObjects:stvNavController, scheduleNavController, nil]; stvTabBarController.selectedViewController = s...

any Cocoa control code that I can use that acts as a patch bay?

I would like to make a patch bay type control... any source online that anyone knows of that I could work from? Thanks ...

How to temporarily lock iPad/iPhone orientation

At a certain point in my application, I would like to temporarily disable the rotation feature - effectively "lock" the orientation in code, similar to what the lock toggle switch does on the iPad in hardware. I'm currently doing: [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications] and when I'm through, I call: [[...

Why set object to nil after sending release message in Obj-C

I see a lot of Objective-C code that has the following syntax when attempting to free objects from memory when they are no longer needed. [controller release], controller = nil; Why set the variable to nil after sending the release message? Isn't release going to free the object no matter what? Why does it need to be set to nil as w...

Scrolling UITableView to valid index path throws error

Why would the following code throw this error? if ([self.tableView.dataSource numberOfSectionsInTableView:self.tableView] > 0 && [self.tableView.dataSource tableView:self.tableView numberOfRowsInSection:0] > 1) { [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0] atScrollPosition:UITableViewScrollPosi...

UITableViewCell data not showing up *initially* in UISplitViewController

I have a generic UISplitViewController (UITableView in the RootViewController and other stuff in the detail view) I have modified UITableViewCells in 2 ways: The rows have a height of 55 The UITableViewCells contain both a UIImage and UILabel There are 50 rows total PROBLEM: When I launch the app, the first 13 rows (the ones that ...

reading time stamp from files in Cocoa?

I want to read when a file is created (or last modified) as it showed in Finder "Date Modified." Is there any existing method in Cocoa can do so? Thanks! ...

Overriding setters not being called in Objective-C

I'm debugging a sample tutorial snippet and am confused about the overriding of setters. I declare and override as shown here: // // PolygonShape.h // @interface PolygonShape : NSObject { int numberOfSides; } @property int numberOfSides; // // PolygonShape.m // @synthesize numberOfSides; // custom setter. - (void) setnumber...

XCode translate matrix ala ActionScript?

Hi gang, I am wondering if there is a way to translate the underlying matrix of a layer much like you can in ActionScript3. In AS3 I can get the transform of a layer and shift it to, let's say, make the center of the layer the anchor point, rather than the upper-left corner. The reason I ask is because I am trying to rotate a layer (c...

UITableView with UIDatePicker ?

Hi, please I need some advice about design approaches in iPhone programming. I want to display a table view (with three cells that will never change) and a UIDatePicker. I don't use Interface Builder. I created a UIViewController subclass and tried to put all together in its viewDidLoad method: UITableView *myView = [[UITableView alloc...

How do I debug weird memory management issues in Xcode/Objective-C?

I'm newish to Objective-C and my memory management skills are not great. However, I haven't had a single problem until now. And now I've got big problems. I've gone from zero crashes to crashing at random points, giving me either no console output or unrecognized selector errors on random types (-[NSCFSet isSameAsStop:]: unrecognized se...

Can I store AVAudioPlayer references in an NSMutableArray and play them at will?

I have a library of 16 short sound clips I need to be able to play in quick succession. I realized that creating and preparing AVAudioPlayer objects in real time was too much to ask of the iPhone. So instead, during my app's initialization, I am pre-creating a series of AVAudioPlayers so that each one is basically pre-loaded with one...

iphone 'No declaration of property 'doSomethingButton' found in the interface' error

I am really confused - I am implementing a change to a button in several views and it works in all but 1 of them and I can't figure out what is different. I have it declared in the .h file : UIButton *doSomethingButton; } @property (nonatomic, retain) IBOutlet UIButton *doSomethingButton; But then in the .m file I get the error ...

Properties and Instance Variables in Objective-C 2.0

Do properties in Objective-C 2.0 require a corresponding instance variable to be declared? For example, I'm used to doing something like this: MyObject.h @interface MyObject : NSObject { NSString *name; } @property (nonatomic, retain) NSString *name; @end MyObject.h @implementation @synthesize name; @end However, what if I did thi...

What is the guaranteed lifecycle of -[NSString UTF8String]?

The docs vaguely say that it will stick around as long as needed, but when is it actually deallocated? When the original NSString is deallocated? When the current autorelease pool clears? Sometime else? Furthermore, when is it guaranteed to stay for, as opposed to the current implementation? If it stays for the lifetime of the NSStr...

ScriptingBridge Finder POSIX path

Hi, is it possible to get the POSIX path or target to the frontmost window using the Scripting Bridge framework? I'm using FinderApplication *theFinder = [SBApplication aplicationWithBundleIdentifier:@"com.apple.Finder"; but I can't find anything in "Finder.h" that could work. ...