Tag Archives: objective-c

Sha256 in Objective-C for iPhone

Questions: When I use this code to create a sha256 of a string unsigned char hashedChars[32]; NSString *inputString; inputString = [NSString stringWithFormat:@”hello”]; NSData * inputData = [inputString dataUsingEncoding:NSUTF8StringEncoding]; CC_SHA256(inputData.bytes, inputData.length, hashedChars); It returns the hash correctly, but I need to insert a string like this \x00\x25\x53 and in this case, the function returns a sha256… Read More »

Sha256 in Objective-C for iPhone

Questions: When I use this code to create a sha256 of a string unsigned char hashedChars[32]; NSString *inputString; inputString = [NSString stringWithFormat:@”hello”]; NSData * inputData = [inputString dataUsingEncoding:NSUTF8StringEncoding]; CC_SHA256(inputData.bytes, inputData.length, hashedChars); It returns the hash correctly, but I need to insert a string like this \x00\x25\x53 and in this case, the function returns a sha256… Read More »

Truncate a string and add ellipsis at the end in Objective-c

Questions: How to truncate a string in Objective-C and then add the ellipsis at the end? Answers: NSString *origString = @”A very long string blah blah blah”; const int clipLength = 18; if([origString length]>clipLength) { origString = [NSString stringWithFormat:@”%@…”,[origString substringToIndex:clipLength]]; } Questions: Answers: Use one of these NSString methods to truncate, probably the last: –… Read More »

Hidden features of Objective-C [closed]

Questions: Objective-C is getting wider use due to its use by Apple for Mac OS X and iPhone development. What are some of your favourite “hidden” features of the Objective-C language? One feature per answer. Give an example and short description of the feature, not just a link to documentation. Label the feature using a… Read More »

Pause/Resume downloads in Objective-C

Questions: Alright. Hopefully this will be my last post about the download manager I am writing in Objective-C. Everything seems to work well except the pause/resume functionality. My issue is that when a download tries to continue from where it left off, it appends the data it receives to the file, but it still seems… Read More »

libphonenumber for iOS or objective-c port

Questions: My goal is to use libphonenumber, google’s phone number handling library for an iPhone project I’m working on. After downloading it (and many many hours), I complied the C++ version of the library, and it built a number “.a” files and “.dylib” files, of which I assumed I must import into my xCodeProject in… Read More »