objective-c

Returning objects with autorelease but I still leak memory

I am leaking memory on this: my custom class: + (id)vectorWithX:(float)dimx Y:(float)dimy{ return [[[Vector alloc] initVectorWithX:dimx Y:dimy] autorelease]; } - (Vector*)add:(Vector*)q { return [[[Vector vectorWithX:x+q.x Y:y+q.y] retain] autorelease]; } in app delegate I initiate it: Vector *v1 = [[Vector alloc] initVector]; Vec...

FBConnect logout button

I am using the FBConnect lib to allow users to post data to their facebook pages. I was successfully able to establish a session and allow a user to post to their wall. My question is this: There is a facebook 'logout' button that is suspended in the top left corner of my view after I've logged into facebook. How do I disable or move ...

Objective C Default parameters?

Possible Duplicates: Optional arguments in Objective-C 2.0? Objective-C Default Argument Value I'm writing a C function in Objective C. I want a default value for my last parameter. I've tried: foo(int a, int b, int c = 0); but that's C++ I've also tried foo(int a, int b, int c) { ... } foo(int a, int b) { foo(a, ...

How do I declare an array as a constant in Objective-c?

The following code is giving me errors: // constants.h extern NSArray const *testArray; // constants.m NSArray const *testArray = [NSArray arrayWithObjects: @"foo", @"bar"]; The error I get is initializer element is not constant Or if I take away the pointer indicator (*) I get: statically allocated instance of Objective-C class ...

objective c import once

I have a header file with a bunch on statics like static NSString * SOME_NAME = @"someMeaning"; What is the best way to import this? Should I define them some other way? I tried just using the #import statement but any file that imports it gives me a warning saying SOME_NAME defined but not used... ...

Determining Screen Positions in Objective-C (NSScreen)

Using [NSScreen screens] I'm able to get all of the screens attached to the computer and their sizes, however I'm trying to find out their positions relative to each other (like in Arrangement in the Display preferences). Is there a way to do this? I've looked online and through the class references on Apple's developer site and found no...

Center Image in UIWebView

Does anybody know a possibility to center simple pictures within a UIWebview without using hmtl/css? Thanks in Advance. ...

Window 'onscreen' size puzzle

Okay, a REALLY fundamental question about window sizes here... If I create an NSWindow in IB, set its size to 216 x 144 points (exactly 3 inches by 2 inches) then print the window, it measures exactly what I set it to in IB. However, the onscreen display size measures approximately 156 x 105 points. What causes this, and is there any w...

Variable Scope Problem, iPhone

Hello all, I need some help here so I will do my best to explain. I have worked on this all day and had no success (just learning!) I have: NSArray *getValue(NSString *iosearch) { mach_port_t masterPort; CFTypeID propID = (CFTypeID) NULL; unsigned int bufSize; kern_return_t kr = IOMasterPo...

How to get objects to react to touches in Cocos2D?

Alright, so I'm starting to learn more about Coco2D, but I'm kinda frusterated. A lot of the tutorials I have found are for outdated versions of the code, so when I look through and see how they do certain things, I can't translate it into my own program, because a lot has changed. With that being said, I am working in the latest versi...

In Objective C, what's the best way to extract multiple substrings of text around multiple patterns?

For one NSString, I have N pattern strings. I'd like to extract substrings "around" the pattern matches. So, if i have "the quick brown fox jumped over the lazy dog" and my patterns are "brown" and "lazy" i would like to get "quick brown fox" and "the lazy dog." However, the substrings don't necessarily need to be delimited by whitesp...

Button to add value to array and then compare result with another array on IPhone.

I have ten buttons that each correspond to a different number. I'm looking to record the order that these buttons are pressed and enter them into an array and then compare it to another array that is static in the app. The check should be done on the Nth button press, where N equals the number of items in the other, static array. How do...

How to post Image with status in Facebook in Iphone sdk?

HI Guys, Here I am having problem that How can I post an image including status in facebook can anyone suggest this. The code I used for posting the status with the inage is as shown below: NSMutableDictionary *args = [[[NSMutableDictionary alloc] init] autorelease]; [args setObject:status forKey:@"caption"]; [[FBRequest requestWithDe...

how to write the array into the sqlite database for objective-c ?

i have taken the data from databse into array now i want it to send it back into database by using the insert query. how can i insert the array of the data into the database. ...

setSelectsInsertedObjects on NSArrayController not actually selecting

I Have an NSArrayController bound to a NSUserDefaults controller, with setSelectsInsertedObjects set to YES in Interface Builder, but when I click Add, the previously select object gets unselected, instead of selecting the newly added object. What am I missing? ...

Printing an invisible NSView

Initially I created a simple program with a custom NSView. I drew a picture (certificate) and printed it! beautiful! Everything worked great! I them moved my custom NSView to an existing application. My hope was that when a user hit print it would print this certificate. Simple enough. I figured a could have a NSView pointer in m...

Objective C: Class Extensions and Protocol Conformation Warnings

I have a large class, which I have divided into several different class extension files for readability. @protocol MyProtocol @required -(void)required; @end @interface MyClass : NSObject <MyProtocol> @end @interface MyClass (RequiredExtension) -(void)required; @end Is there a better way to do this, without the compiler warning? w...

iPhone: How to Define and Use a Custom UITableViewCell from a Nib File.

Hi, I'm trying to create a single custom UITableViewCell from a xib, among other normal UITableViewCell's. I've tried quite a few varied things with no success. Can anyone help me please? ...

Attributed strings in UITableViewCells without WebView?

Hello, does anyone know if there's a way in with 3.0+ to display attributed strings within a UITableViewCell without using a UIWebView for that? I need to display a string with linked, tappable substrings as the typical detailTextLabel. I wouldn't mind exchanging this UILabel against another type of view, but I think a UIWebView could b...

Make new chat in Adium using Cocoa ScriptingBridge

The following AppleScript code works fine: tell application "Adium" to tell first account to make new chat with contacts {first contact} with new chat window But how can I do the same using Cocoa's ScriptingBridge? ...