LoginSignup
1
0

More than 5 years have passed since last update.

objective-cでズンドコゲッター

Last updated at Posted at 2016-05-29

概要

objective-cでズンドコゲッター、やってみた。

実際

サンプルコード

#import <Foundation/Foundation.h>
#include <stdlib.h>

NSString * zundoko(void) 
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    NSURL * url = [NSURL URLWithString:@"http://ohijs0.paas.jp-e1.cloudn-service.com/zundoko"];
    NSURLRequest * request = [[NSURLRequest alloc] initWithURL:url];
    NSError * error;
    NSURLResponse * response;
    NSData * data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    NSString * r = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    return r;
}
int main(void)
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    NSString * str1 = @"ドコ";
    NSString * str2 = @"ズン";
    NSString * s = @"";
    int i = 0;
    while (true)
    {
        NSString * a = zundoko();
        if ([a isEqualToString:str1])
        {
            s = [NSString stringWithFormat: @"%@%@ ", s, str1];
            if (i == 4) break;
            i = 0;
        }
        else
        {
            s = [NSString stringWithFormat: @"%@%@ ", s, str2];
            i++;
        }
    }
    s = [NSString stringWithFormat: @"%@%@", s, @"キ・ヨ・シ!"];
    [[NSFileHandle fileHandleWithStandardOutput] writeData: [s dataUsingEncoding: NSUTF8StringEncoding]];
    [pool release];
    return 0;
}

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0