Skip to main content

Posts

Showing posts with the label nsstring

how to split strings in objective c

How to split a string in objective-C? I am working on an short application that contains a date picker. I do display date get it from date picker and display it through a label. My main question is that how can I split the the date in to three separate strings? any one has idea about it? thanks Muhammad Naveed

how to encode a UInt32 scalar type into a NSData object

I am currently creating this NSData object. I would like to put in sever different objects that are of type NSString and UInt32. I know how to put a NSString into my NSData object, but I don't know how to do this with a UInt32 scalar type. this is how I do it with a NSString - (void) constructRequest { NSString *mystring = [[NSString alloc] initWithString:[self addMethodName]]; UInt32 protocolInt = [self addProtocolVersion]; NSData* data=[mystring dataUsingEncoding:NSUTF8StringEncoding]; [data writeToFile:@"/Users/imac/Desktop/_dataDump.dat" atomically:YES]; }

Accurately Converting NSString to GLFloat - iPhone

Say I have some vertice values which I am reading into my app as a NSString : -7501.6 -6198.2 834.939 -5547.66 -6348.32 2122.65 The values in the source are always 6 figures in length. I need to pass these exact values to OpenGL. If I try to cast as a float (using NSString floatValue) then, as expected, I get an approximate value for each float due to the inexact nature of a float : -7501.600098, -6198.200195, 834.939026 -5547.660156, -6348.319824, 2122.649902 Can anyone suggest a way that I can get these values into OpenGL and retain their exact initial integrity ? Thank you.

Convert an iPhone phone number format for a "dial-able” string

I am building an iphone app that reads a phone number from the address book and dial it (with some other things of course...:)). When I load the phone numbers from the AB they are in this following format: "1 (111) 111-1111" which is not "dial-able" when using this: fullNumber = [NSString stringWithFormat:@"%@%@", @"tel:", phoneNum]; Why is that happening? What would be the best way to approach this? How could I convert the phone number into a string of digits (with no spaces or "-")? Thanks.