cocoa-touch

Convert NSData from local NSURL

南楼画角 提交于 2019-12-25 12:07:33
问题 I have a sound player which uses AVAudioPlayer class. I download some items in another view and store the filepath to it as NSURL, then pass the NSURL to the Player viewcontroller. But i get an error while trying to pass the object. *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString path]: unrecognized selector sent to instance 0x1700c86c0' And here is the code: NSData *data = [NSData dataWithContentsOfFile:[podcastSource path]]; NSError *error

UIImage uplaod to rest server the orientation will chage?

梦想的初衷 提交于 2019-12-25 12:04:44
问题 The camera take photo,upload to api successful but the Image orientation will turn left. NSData *data = [[[NSMutableData alloc] initWithData:imageData] autorelease]; NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"file"]; BOOL _B = [data writeToFile:path atomically:YES]; if (!_B) { NSLog(@"write to file error!"); return; } [request addFile:path forKey:@"photofile"]; Why? 回答1: OK,I resoloved this issue. - (UIImage *

UIImage uplaod to rest server the orientation will chage?

丶灬走出姿态 提交于 2019-12-25 12:04:32
问题 The camera take photo,upload to api successful but the Image orientation will turn left. NSData *data = [[[NSMutableData alloc] initWithData:imageData] autorelease]; NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"file"]; BOOL _B = [data writeToFile:path atomically:YES]; if (!_B) { NSLog(@"write to file error!"); return; } [request addFile:path forKey:@"photofile"]; Why? 回答1: OK,I resoloved this issue. - (UIImage *

UIImage uplaod to rest server the orientation will chage?

♀尐吖头ヾ 提交于 2019-12-25 12:04:20
问题 The camera take photo,upload to api successful but the Image orientation will turn left. NSData *data = [[[NSMutableData alloc] initWithData:imageData] autorelease]; NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"file"]; BOOL _B = [data writeToFile:path atomically:YES]; if (!_B) { NSLog(@"write to file error!"); return; } [request addFile:path forKey:@"photofile"]; Why? 回答1: OK,I resoloved this issue. - (UIImage *

UIImage uplaod to rest server the orientation will chage?

徘徊边缘 提交于 2019-12-25 12:04:17
问题 The camera take photo,upload to api successful but the Image orientation will turn left. NSData *data = [[[NSMutableData alloc] initWithData:imageData] autorelease]; NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"file"]; BOOL _B = [data writeToFile:path atomically:YES]; if (!_B) { NSLog(@"write to file error!"); return; } [request addFile:path forKey:@"photofile"]; Why? 回答1: OK,I resoloved this issue. - (UIImage *

How do I make a button stay pressed?

随声附和 提交于 2019-12-25 11:32:11
问题 Okay so I have an app I'm building that is almost complete. I'm just having one problem, when I press my button it makes a sound and the button's image changes. However the image only changes when it is being touched or "highlighted" and I would like the buttons image to remain changed through the duration of the sound effect then after the sound effect I would like it to revert back to the original image. Is there anyway I can set up a UIButton "set time" or something for the "highlighted"

NSPredicate issue using with numberOfRowsInSection method

牧云@^-^@ 提交于 2019-12-25 09:30:01
问题 I am trying to implement search for UITableView. First I fill my array of historical periods from DB in - (void)viewDidLoad method. self.periodsArr=[dbAccsess getPeriods:subCountryID]; self.searchBar = [[[UISearchBar alloc]initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 44.0f)] autorelease]; searchBar.delegate=self; self.tableView.tableHeaderView = self.searchBar; searchBar.keyboardType=UIKeyboardTypeNumberPad; self.searchController = [[[UISearchDisplayController alloc] initWithSearchBar:self

subclassing initWithFileURL of an UIDocument

风格不统一 提交于 2019-12-25 09:08:54
问题 I'm trying to overwrite the initWithFileURL of an UIDocument as I need to call some custom methods once an UIDocument is initialised. I thought this may be a good idea: -(id)initWithFileURL:(NSURL *)url { self = [super initWithFileURL:url]; // do some custom stuff return self; } Is there anything else I need to do if I overwrite this? I have the feeling that I need to check for NIL or something. Where do you usually look if you need to overwrite a method with something custom? I was only able

A mutex blocks only the main thread when it reaches its call with the @synchronized directive

时光毁灭记忆、已成空白 提交于 2019-12-25 09:00:35
问题 I'm building a multithreaded application, from which more than one thread can write to an sqlite3 database including the main thread. I declared a static public variable to be used for the mutex: @implementation Application #pragma mark - #pragma mark Static Initializer static NSString * SubmitChangesLock = nil; + (void)initialize { [super initialize]; SubmitChangesLock = [[NSString alloc] initWithString:@"Submit-Changes-Lock"]; } + (NSString *)submitChangesLock { return SubmitChangesLock; }

Update ULabel immediately while downloading files

泄露秘密 提交于 2019-12-25 08:57:43
问题 I am using NSURLConnection to download the files . I have a UILabel in my View which has to display the currently downloading files. The UILabel is getting updated at the starting and the end. Lets say I am download 10 files. I am able to set the Label text before start downloading and after completing the download. I can understand that, the method which I am trying to call is not running in main thread, So I have used the following code to make it run in the main thread , [_myHome