nsstring

AVAssetExportSession outputfile

匿名 (未验证) 提交于 2019-12-03 03:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How should the AVAssetExportSession output file look like? I'm trying to compress a video from an ALAsset item and it doesn't work. I'm guessing the output file has something to do with it. Here's the code i'm using: NSString *destinationPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie"]; [self convertVideoToLowQualityWithInputURL:asset.defaultRepresentation.url outputURL:[NSURL URLWithString:destinationPath]]; - (void)convertVideoToLowQualityWithInputURL:(NSURL*)inputURL outputURL:(NSURL*)outputURL { if([

Append a newline to an NSString

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have this: if (soapResults != nil) { soapResults = [soapResults stringByAppendingString:@"\n"]; } But I get a warning: Assignment from distinct Objective-C type on build. When I run it on device I get: Program received signal: "EXC_BAD_ACCESS". from gdb. Any ideas how to append a newline to an NSString without getting a warning or error? Any help appreciated // :) 回答1: An alternative is: [NSString stringWithFormat: @"%@\n", soapResults] even if the logic is the same! However, even in the case of stringByAppendingString, it returns a new

casting a NSString to char problem

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i want to casting my NSString to a constant char the code is shown below : NSString *date = @"12/9/2009"; char datechar = [date UTF8String] NSLog(@"%@",datechar); however it return the warning assignment makes integer from pointer without a cast and cannot print the char properly,can somebody tell me what is the problem 回答1: Try something more like this: NSString* date = @"12/9/2009"; char* datechar = [date UTF8String]; NSLog(@"%s", datechar); You need to use char* instead of char, and you have to print C strings using %s not %@ (%@ is for

NSTask NSPipe - objective c command line help

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Here is my code: task = [[NSTask alloc] init]; [task setCurrentDirectoryPath:@"/applications/jarvis/brain/"]; [task setLaunchPath:@"/applications/jarvis/brain/server.sh"]; NSPipe * out = [NSPipe pipe]; [task setStandardOutput:out]; [task launch]; [task waitUntilExit]; [task release]; NSFileHandle * read = [out fileHandleForReading]; NSData * dataRead = [read readDataToEndOfFile]; NSString * stringRead = [[[NSString alloc] initWithData:dataRead encoding:NSUTF8StringEncoding] autorelease]; So I'm trying to replicate this: cd /applications

Instagram InstagramCaption not working

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have below code for sharing article on Instagram. -(void) shareInstagram { NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"]; if([[UIApplication sharedApplication] canOpenURL:instagramURL]) //check for App is install or not { UIImage *instaImage = mImg.image; NSData *imageData = UIImagePNGRepresentation(instaImage); //convert image into .png format. NSLog(@"imageData.leeee===%d", imageData.length); if (imageData.length<=100) { [self.view makeToast:localize(@"instaErr2") duration:2.0 position:@"bottom"]; } else { NSFileManager

Objective-C: Weak attritube don&#039;t work as expected [duplicate]

匿名 (未验证) 提交于 2019-12-03 03:05:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Possible Duplicate: Why do weak NSString properties not get released in iOS? I'm a newbie to Objective C and I've got some questions that I cannot answer myself. I have a block of code for testing __weak variable (I'm using ARC, of course): NSString *myString = [[NSString alloc] initWithFormat:@"John"]; NSString * __weak weakString = myString; myString = nil; //<-- release the NSString object NSLog(@"string: %@", weakString); The output of the above codes is as expected, since weakString is a weak variable : 2013-01-02 11:42:27.481

How to convert NSDictionary to custom object

匿名 (未验证) 提交于 2019-12-03 03:05:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a json object: @interface Order : NSObject @property (nonatomic, retain) NSString *OrderId; @property (nonatomic, retain) NSString *Title; @property (nonatomic, retain) NSString *Weight; - (NSMutableDictionary *)toNSDictionary; ... - (NSMutableDictionary *)toNSDictionary { NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init]; [dictionary setValue:self.OrderId forKey:@"OrderId"]; [dictionary setValue:self.Title forKey:@"Title"]; [dictionary setValue:self.Weight forKey:@"Weight"]; return dictionary; } In string this is:

How to detect if NSString contains a particular character or not?

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i have one NSString object , for ex:- ($45,0000) Now i want to find if this string contains () or not How can i do this? 回答1: Are you trying to find if it contains at least one of ( or ) ? You can use -rangeOfCharacterFromSet: : NSCharacterSet *cset = [NSCharacterSet characterSetWithCharactersInString:@"()"]; NSRange range = [mystr rangeOfCharacterFromSet:cset]; if (range.location == NSNotFound) { // no ( or ) in the string } else { // ( or ) are present } 回答2: The method below will return Yes if the given string contains the given char -

UIAlertView first deprecated IOS 9

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have tried several ways to use UIAlertController,instead of UIAlertView. I tried several ways but I cannot make the alert action work. Here is my code that works fine in IOS 8 and IOS 9 but is showing up with deprecated flags. I tried the elegant suggestion below but I can't make it function in this context. I need to submit my app and this is the last thing to address. Thank You for any further suggestions. I am a newbie. #pragma mark - BUTTONS ================================ - (IBAction)showModesAction:(id)sender { NSLog(@"iapMade: %d",

Got “is not a recognized Objective-C method” when bridging Swift to React-Native

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to bridge my React-Native 0.33 code to a super simple Swift method, following this guide but all I'm getting is show:(NSString *)name is not a recognized Objective-C method . Here's my code: SwitchManager.swift import Foundation @objc(SwitchManager) class SwitchManager: NSObject { @objc func show(name: String) -> Void { NSLog("%@", name); } } SwitchManagerBridge.h #import "RCTBridgeModule.h" @interface RCT_EXTERN_MODULE(SwitchManager, NSObject) RCT_EXTERN_METHOD(show:(NSString *)name) @end SwitchManager-Bridging-Header.h #import