objective-cでズンドコゲッター
1708 ワード
概要
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;
}
#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;
}
Author And Source
この問題について(objective-cでズンドコゲッター), 我々は、より多くの情報をここで見つけました https://qiita.com/ohisama@github/items/28af06b41180ac5502ff著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .