objective-c

Make QTMovieView full screen

I have a QTMovieView set up as an IBOutlet. I want to play the video in full screen. Which method allows this? ...

Objective-C: how to delcare a static member that is visible to subclasses?

Hi Im declaring a family of static classes that deals with a communications protocol. I want to declare a parent class that process common messages like ACKs, inline errors... I need to have a static var that mantain the current element being processed and I want to declare it in the parent class. I do it like this: parent.m @implem...

Is there a convenient function in objective-c / coca-touch to find a lowest number?

I have two numbers, and need to get returned the lower one. Is there any function I could use? Sure it's a easy task, I could do an if-statement. I just want to know. ...

Why does Clang complain about all my autoreleased objects?

I have the following function: - (NSString *)urlEncodedValue { NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes( kCFAllocatorDefault, (CFStringRef)self, NULL, CFSTR("?=&+/\r\n"), kCFStringEncodingUTF8 ); return [result autorelease]; } Why is Clang giving me the following c...

Obj-C syntax error on if statement... Why?

Hi! REAL newbie here to Objective C and Cocoa. I have this 'if statement' if (cardCount = 2) UIImage *image = [UIImage imageNamed: @"Card 2.png"]; This gives me "error: syntax error before '*' token" Why? The UIImage line works fine by itself. I'd appreciate a pointer to what I've done wrong. Thanks Paul ...

How would you make a status item's title be an image not text?

I have created a status item (menu bar item) for my app, but at the moment it's title is text, how would I make it show an image? This is the part of the code which sets the title. What would I need to change to that code to make it display an image? [item setTitle:@"MenuItem"]; ...

Regex solution for Objective-C

What is the best method for using Regular Expressions within Objective-C? There seems to be some open source project that provide regex support, can any one recommend one? Also I looked at NSPredicate, can anyone suggest any regex examples? Background: I want use regex mainly for validation, IP's, email addresses, internal ID's etc ...

Reusing a NSString variable - does it cause a memory leak?

Coming from a .NET background I'm use to reusing string variables for storage, so is the code below likely to cause a memory leak? The code is targeting the iphone/itouch so no automatic GC. -(NSString*) stringExample { NSString *result = @"example"; result = [result stringByAppendingString:@" test"]; // where does "example" go?...

Join an Array in Objective-C

I'm looking for a method of turning a NSMutableArray into a string. Is there anything on a par with this Ruby array method? >> array1 = [1, 2, 3] >> array1.join(',') => "1, 2, 3" Cheers! ...

Is there a way to enable both Objective-C mode and C++-mode at the same time in emacs?

I'm working with some Objective-C++ code (.mm files), and I'm curious if it's possible to get emacs to use proper syntax highlighting for both the Objective-C parts and the C++ parts. objc-mode and c++-mode are both major modes (built on top of cc-mode), so they can't be used at the same time. Are there any minor modes or elisp hacks a...

iPhone check firmware version

HI all I want to make one app for iPhone 2.2.* and for version 3.0. Some method in 2.2* is deprecated in 3.0. ( like UITableViewCell setText and setLabel ) Is there any way to check which firmware version is used on iPhone and to set different method to use ...

How do I represent a void pointer in a PyObjC selector?

I'm wanting to use an NSOpenPanel for an application I'm designing. Here's what I have so far: @objc.IBAction def ShowOpenPanel_(self, sender): self.panel = NSOpenPanel.openPanel() self.panel.setCanChooseFiles_(False) self.panel.setCanChooseDirectories_(True) NSLog(u'Starting OpenPanel') self.panel.beginForDirectory...

Why "cannot use an object as a parameter to a method"?

I have the following ViewController class #import <UIKit/UIKit.h> @interface SampleViewController : UIViewController { IBOutlet UITextField *field1; } @property (nonatomic, retain) UITextField *field1; - (IBAction) method1:(id)sender; @end When I change the method1:(id)sender to method1:(UITextField)sender, I get the error "Ca...

How do I check what current view is?

I want to check what the current view is objective c (in cocoa touch) Could I do something like this? if (viewA == current view) { run code here } Thanks ...

Absolute Value (abs) of NSDecimalNumber without loss of precision

I need to get the absolute value of an NSDecimalNumber without loss of precision. I can't seem to find a way to do this without converting to decimal or float (with a loss of precision). Is there a method to do this? ...

Atomic, asynchronous HTTP file POST with sensible feedback?

Hello! I've just started development on Macs and have found Cocoa to be a useful and thoughtful framework, but its HTTP functionality has me puzzled. I have an NSURLConnection object to download a file from my webserver using the HTTP GET method. NSURLConnect's asynchronous connection is great, I get plenty of feedback, I get each chun...

Disable automatic selection of a row after as NSTableView is populated

I have two NSTableViews populated with Core Data that are linked using bindings. When a row is selected in NSTableView1, NSTableView2 is populated and the first row in it is selected. I have registered the NSArrayController that corresponds to NSTableView2 with KVO on its selectionIndex. This is so that when a row is selected in NSTab...

Design Pattern Help: Pool of unique objects

I'm looking for a design pattern to manage a pool of objects. A thread can request an object, in my case an object representing a remote host. If the host-object does not exist it is created, added to the pool and a reference returned. If another thread or object requests the same (remote host) object it too is given the reference. If ...

Objective-C 2.0: class_copyPropertyList(), how to list properties from categories

I tried to list all properties of an Objective-C class like described in the Objective-C 2.0 Runtime Programming Guide: id LenderClass = objc_getClass("UIView"); unsigned int outCount, i; objc_property_t *properties = class_copyPropertyList(LenderClass, &outCount); for (i = 0; i < outCount; i++) { objc_property_t property = properti...

Are there strongly-typed collections in Objective-C?

I'm new to Mac/iPhone programming and Objective-C. In C# and Java we have "generics", collection classes whose members can only be of the type declared. For example, in C# Dictionary<int, MyCustomObject> can only contain keys that are integers and values that are of type MyCustomObject. Does a similar mechanism exist in Objective-C...