Alcatraz The package manager for Xcode.
https://github.com/supermarin/Alcatraz
curl -fsSL https://raw.github.com/supermarin/Alcatraz/master/Scripts/install.sh | sh
| - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string | |
| { | |
| NSString *currentStr; | |
| if ((range.length == 0 && string.length > 0) || (range.length > 0 && string.length > 0)) { | |
| // add the characters to textfield | |
| NSString *firstHalfStr = [textField.text substringToIndex:range.location]; | |
| NSString *lastHalfStr = [textField.text substringFromIndex:(range.location + range.length)]; | |
| currentStr = [NSString stringWithFormat:@"%@%@%@",firstHalfStr,string,lastHalfStr]; |
| - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | |
| { | |
| Contact* contact = [self.contacts objectAtIndex:indexPath.row]; | |
| UITableViewCell *cell = nil; | |
| static NSString *cellId = @"Cell"; | |
| cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:cellId]; | |
| if (cell == nil) { | |
| cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId] autorelease]; | |
| } | |
| UILabel *firstLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
| // src : file's url | |
| // file : file's name on the disk | |
| // return : file's path on the disk | |
| - (NSString*)catchFileFrom:(NSString*)src toFile:(NSString*)file | |
| { | |
| NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
| NSString *filePath = [NSString stringWithFormat:@"%@/%@", [paths objectAtIndex:0],file]; | |
| NSURL *url = [NSURL URLWithString:src]; |
| -(BOOL)dataIsValidJPEG:(NSData *)data | |
| { | |
| if (!data || data.length < 2) return NO; | |
| NSInteger totalBytes = data.length; | |
| const char *bytes = (const char*)[data bytes]; | |
| return (bytes[0] == (char)0xff && | |
| bytes[1] == (char)0xd8 && | |
| bytes[totalBytes-2] == (char)0xff && |
| // information comes from http://stackoverflow.com/questions/3339722/how-to-check-ios-version | |
| //------------------------------------- | |
| // you can use this in your code | |
| if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) { | |
| // Load resources for iOS 6.1 or earlier | |
| } else { | |
| // Load resources for iOS 7 or later | |
| } |
| - (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch | |
| { | |
| if ([gestureRecognizer isEqual:self.tapRecognizer]) { | |
| // for ios 7 , need to compare with UITableViewCellContentView | |
| if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"] || [touch.view.superview isKindOfClass:[UITableViewCell class]]) { | |
| return FALSE; | |
| } | |
| } | |
| return TRUE; | |
| } |
https://github.com/supermarin/Alcatraz
curl -fsSL https://raw.github.com/supermarin/Alcatraz/master/Scripts/install.sh | sh