Late Update

Is kind of an oxymoron but that’s ok because oxymorons tickle my brain in a good way. My favorite is definitely “random order”.

Anyway, I wrote some code that helps grab a section of a string (substring) from a larger string, without knowing what’s between the two strings. So it’s kind of useful for scanning/parsing a chunk of data. (look below for application)

The functions:

-(NSInteger)getScanLocation:(NSString *)content toString:(NSString *)lookup {

NSScanner *scanner = [NSScanner scannerWithString:content];

[scanner scanUpToString:lookup intoString:nil];

return [scanner scanLocation];

}

-(NSString *)grabInfo:(NSString *)content fromString:(NSString *)lookup {

NSInteger startScan = [self getScanLocation:content toString:lookup];

NSInteger lengthOfInfo = [content length];

NSRange start_range = NSMakeRange(startScan,(lengthOfInfo - startScan));

NSString *info = [content substringWithRange:start_range];

return info;

}

-(NSString *)getSection:(NSString *)content fromString:(NSString *)startString toString:(NSString *)endString {

NSString *first = [self grabInfo:content fromString:startString];

NSInteger endScan = [self getScanLocation:first toString:endString];

NSRange end_range = NSMakeRange(0, endScan);

NSString *final = [first substringWithRange:end_range];

return final;
}

As you could probably tell it’s not fully optimized or anything but for now it works. The application would look something like…

You have some NSString “data” e.g.

<example data>blahblah<data>/\/\/\120934u534814[j 109]<more crap><random order><chaos control>120938103453410

<more data><this is a lot of data we’re talking about here><what><yes><no>10348304803410922<oh man><test>

Now say I want what’s in bold, I would type:


NSString *data_section = [self getSection:data fromString:@"<more data>" toString:@"<yes>"];

Questions? Thoughts? Comments? Concerns?

Advertisements

New Rule

From now on I decree I shall post whenever I feel like it! I realize that then the week is through I forget what I wanted to post about. I know I should really write this shit down.

Anyway, personal progress update on my Facebook contact synchronization app. (PPUFCSA) I’ve actually found a way to differentiate myself in multiple ways from current apps. (There are 9 or so I think) Although I cannot disclose those ways publicly I will say that one of them may result in the banning of my app from the app store. We will see soon enough.

In game development news on draconem: I’ve decided to rename the game “Dragon Fierce” partly because it sounds like the name of a game I would have played on Super Nintendo, and another part being the trend of iOS games having Angry/Upset animals in their titles. “Angry Birds” (obv), “Unpleasant Horse”, “Battle Bears”, “Crazy Hamster”, “Angry/Crazy Penguin” (original/sequel)…  uhhh “Sushi Cat”?.. ok that last one doesn’t follow but I know there are others. I also am being helped by a talented artist who has been involved in some Nintendo DS titles and ports to XBLA. I’m not sure how much he’ll help me out with Dragon Fierce (this would be for profit sharing) but I’m down to work with him. More on that later…