小数 (0 ~ 1.0)
double drand48()
これだけ!!
整数 (0 ~ x)
xが100の場合
int someinteger = arc4random() % 100
このとき生み出される数の範囲は0 <= x <= 99
99までしか生み出されない。
こんな感じ。
整数で望む範囲の数を取得するにはちょっと注意が必要かも。
- (BOOL) isEmpty:(NSString *)string {
if([string length] == 0) { //string is empty or nil
return YES;
}
if(![[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length]) {
//string is all whitespace
return YES;
}
return NO;
}
//1. まずQuartzCore.frameworkを使用する
// 2. つぎにFirstViewContorller.mとか使用したいmファイルでQuartzCoreをimport
// 3. あとは使用したいところに以下のように指定する
self.text.layer.borderColor = [UIColor grayColor].CGColor;
self.text.layer.borderWidth = 1.0;
self.text.layer.cornerRadius = 4.0;
//table delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 100;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[UITableViewCell alloc]init];
static NSString *CellIdentifier = @"OneQuestion";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
return cell;
}
-(void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath{
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
}