Skip to main content

Posts

Showing posts with the label uint32

creating an http body with construction method

I am trying to create a http body that I am going to pass in using NSURLRequest post. I have my connection class all set up. The thing is i have several methods that return NSStrings and UInt32's and one construction method that I want to use to put all of these methods into one http body which will be of data type format. However I'm not sure how to call these methods that return the correct data from my construction method to gather the data into one data object. here is some code that I have (shortened so its a little clearer) these methods are used to return the data needed - (UInt32) addDataVer { UInt32 dataVer = 0; return dataVer; } - (NSString *) addReg { NSString *reg = [[NSString alloc] initWithString:@"abcd1"]; return reg; } - (NSString *) addActiv { NSString *activ = [[NSString alloc] initWithString:@"abcd2"]; return activ; } from here I'm not sure what to do, or how to get the data. I have created a constru

how to pass NSUserDefaults integer to a UInt32 object

I am wondering if it is possible to pass an integer value I am creating in my NSUserDefaults into a UInt32 object? So far I am creating the NSUserDefaults as below. NSString * yourKey = @"RequestNumber"; NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; [defaults setInteger:[defaults integerForKey:yourKey] + 1 forKey:yourKey]; and then I am trying to pass the user defaults value into my object as below.. However I am fairly positive I am completely wrong... which is why im here :) any help would be appreciated. UInt32 *requestNumber = [[NSUserDefaults standardUserDefaults] integerForKey:yourKey];

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]; }