objective-c

Import RSA keys to iPhone keychain?

I have a couple of NSString objects that represent an RSA public-private keypair (not generated by SecKeyCreatePair, but by an external crypto library). How can I create SecKeyRef objects (which are required for the SecKeyDecrypt/Encrypt methods) from these NSString objects? Do I need to import them into the Keychain first? If so, how? ...

Formatting URL parameters in an NSURL object

I want to pass parameter in NSURL i.e. I have NSURL *url = [NSURL URLWithString:@"http://demo.digi-corp.com:82/Nilesh/betBuddy/api/getEventsXML.php?sp_ID=2"]; where sp_ID can be 1,2,3,4 etc. how can i do it?? plz help me out? ...

How can I make a weak reference to a parent object when using properties?

I am not sure about it. Would I do that this way? @property(nonatomic) MyParentObject *parentObject; Note that I just left out the retain Keyword. Or would I have to write the Setter by myself? ...

Is there anything like a generic list in Cocoa / Objective-C?

What I really like in C# are generic lists. A list that can contain only one type of objects. Is there something like a generic list in Cocoa/Objective-C? As far I only know NSArray who will take a pointer to any object. ...

Cocoa, Flicker with animation when overlaying a NSWindow on a QTMovieView

In a project that I am currently working on I have an transparent NSWindow overlayed on a QTMovieView. At certain points I slide a custom view into this child window with animation so that it is displayed over the movie for a short period of time. The only odd behavior is that the animation is smooth on a Mac Book Pro but on a Mac Book(S...

SQLite DB Wrapper Not Responding to Message? Unrecognized Selector!

Hey Folks, I'm developing for iphone-sdk 2.2.1 (so no CoreData cry). So I'm using the FMDatabase project, which is just a SQLite Wrapper in Obj C. I have my DB working well when interacting with it from my AppDelegate. I've tested connecting, INSERTING, etc from the AppDelegate. Now, I have a data object that I want to store into th...

Converting to Precomposed Unicode String using Python-AppKit-ObjectiveC

This document by Apple Technical Q&A QA1235 describes a way to convert unicode strings from a composed to a decomposed version. Since I have a problem with file names containing some characters (e.g. an accent grave), I'd like to try the conversion function void CFStringNormalize(CFMutableStringRef theString, CFS...

to extract a part of the URl after XML parsing?

Hi Guys.. I am trying to parse an XML file in which an element named "description" is as given below: <description><![CDATA[<a href='http://www.okmagazine.com/posts/view/13756/'&gt;&lt;img src='http://www.okmagazine.com/img/photos/thumbs/27044' /></a><br />Ashlee and Pete take their tiny tot to FAO Schwarz in NYC for some new toys. <p...

How to split a string literal across multiple lines in C / Objective-C?

I have a pretty long sqlite query: const char *sql_query = "SELECT statuses.word_id FROM lang1_words, statuses WHERE statuses.word_id = lang1_words.word_id ORDER BY lang1_words.word ASC"; How can I break it in a number of lines to make it easier to read? If I do the following: const char *sql_query = "SELECT word_id ...

What technique should i use to replicate the Compose email view in an iphone App?

So I have an Application that involves sending emails through an API. What I would like is that to have the same or similar to compose email interface available on the phone already. Unfortunately in all apples Goodness there is no view that just does that. [AppleComposeMailViewController alloc]; Would do the trick nicely...

iPhone SQLite - getting sqlite3error()

Hi I am trying to reuse a sqlite statement in my application in a method. Here's the relevant code if(getsets_statement == nil){ const char *sql = "SELECT DISTINCT num,roll FROM mytable WHERE cls like ? and divname like ?"; if(sqlite3_prepare_v2(database, sql, -1, &getsets_statement, NULL) != SQLITE_OK){ NSAssert1(0, @"Error: Faile...

Objective-c Iphone how to set default value for a property.

Hi i've got the following code in a ViewController.h: #import <UIKit/UIKit.h> @interface CalcViewController : UIViewController { NSNumber* result; NSString* input; //NSString* input = @""; IBOutlet UITextField* display; } @property (retain) NSNumber* result; @property (retain) NSString* input; @property (nonatomic, re...

C Macros to create strings

I would like to use C #define to build literal strings at compile time. The string are domains that change for debug, release etc. I would like to some some thing like this: #ifdef __TESTING #define IV_DOMAIN domain.org //in house testing #elif __LIVE_TESTING #define IV_DOMAIN test.domain.com //live testing servers #else ...

How to write a simple Ping method in Cocoa/Objective-C

I need to write a simple ping method in Cocoa/Objective-C. It also needs to work on the iPhone. I found an example that uses icmp, will this work on the iPhone? I'm leaning towards a solution using NSNetServices, is this a good idea? The method only needs to ping a few times and return the average and -1 if the host is down or unreach...

Can you add a property at run-time when coding with Objective-C

I was wondering if it is possible at run-time to dynamically add new properties to an Objective-C object instance? My initial thought would just to overrride the getValueForKey to "fake" a property but it seems like this doesn't work with CoreAnimation. What I want to achieve is to be able to animate custom properties. I have been able...

What does "Leak of returned object" mean, from Clang?

Further to this question I've fixed a bunch of memory leaks in BEncoding.m (originally from here) I've fixed all the obvious memory leaks, but Clang has found four "Leak of returned object" bugs, which I'm not sure how to sort: The full messages/appropriate bits of code are: NSMutableData *data = [[NSMutableData alloc] init]; [...

C preprocessor on Mac OSX/iPhone, usage of the '#' key?

I'm looking at some open source projects and I'm seeing the following: NSLog(@"%s w=%f, h=%f", #size, size.width, size.height) What exactly is the meaning of '#' right before the size symbol? Is that some kind of prefix for C strings? ...

Best practices for validating email address in Objective-C?

What is the cleanest way to validate an email address that a user enters that is Cocoa-Touch 2.0 compatible? ...

do I need to explicitly alloc my NSNumber?

I am defining a number, as follows: NSNumber *nn0 = [NSNumber numberWithInt:0]; It works fine without any alloc. My understanding is that if I use numberWithInt, alloc and init are called automatically. If I try to release at the end of my function, I run into problems: [nn0 release]; I get a runtime error. My question is: if I us...

jpg or png for UIImage -- which is more efficient?

I am grabbing an image from the camera roll and then using it for a while as well as save it to disk as a PNG on the iPhone. I am getting the odd crash, presumably due to out of memory. Does it make a difference if I save it as PNG or JPG (assuming I choose note to degrade the quality in the JPG case)? Specifically: is more memory t...