我试图从Array.But创建一个字符串,有如何生成它的条件,如下所述.
NSArray *array=[NSArray arrayWithObjects:@"Hello",@"World",nil];
[array componentsJoinedByString:@","];
Run Code Online (Sandbox Code Playgroud)
这将输出:Hello,World.
但是,如果第一项是空的,那么是否有办法接收唯一的第二项.
我有以下文件结构用于本地化.
A.xib
- > A.xib(基础)
- > A.strings(西班牙语)
- > A.strings(英文)
因为它是"使用基础国际化".我们可以期望只有一个xib文件和本地化所需的字符串文件.
但是,当我将此字符串文件转换为.xib时(我们的每种语言都有.xib文件.在Base Internationalization之前就是这种情况).事情开始在iOS模拟器上工作,设备响应这些变化.
注意: - 我还尝试重置模拟器,清理并创建构建但没有成功.
当我使用.strings文件进行本地化时,不知道为什么本地化失败了.
任何帮助,一个小错误在Xcode IDE上消耗更多时间和耗费开发时间.
我在settings.bundle中添加"Version Detail".什么是设置该标识符的更好方法,我看到很少通过代码使用Plistbuddy的运行脚本来完成.
是这样的,如果你使用plistbuddy,它会立即显示更新版本的详细信息,即使你没有打开应用程序.从应用程序版本更新后.商店?
如果通过代码完成,则必须打开应用程序.在设置中查看更新.
我有以下代码在UIView中显示标记.标记显示效果很好,一旦我们尝试使用变换进行缩放和缩放UIView,即使在调用setNeedsDisplay之后,第一个绘图仍保持原样.
我的自定义UIView子类具有以下代码
- (void)drawRect:(CGRect)rect
{
// Drawing code
CGFloat w=20.0f;
CGFloat h=8.0f;
CGContextRef context=UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor blueColor].CGColor);
CGContextClearRect(context,self.bounds);
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
CGContextSetLineCap(context, 2.0);
CGMutablePathRef leftMarker=CGPathCreateMutable();
CGPathMoveToPoint(leftMarker, NULL, 0, 0);
CGPathAddLineToPoint(leftMarker, NULL, w, 0);
CGPathAddLineToPoint(leftMarker,NULL, w, h);
CGPathAddLineToPoint(leftMarker,NULL, h, h);
CGPathAddLineToPoint(leftMarker,NULL,h, w);
CGPathAddLineToPoint(leftMarker,NULL,0, w);
CGPathAddLineToPoint(leftMarker,NULL, 0, 0);
CGContextAddPath(context, leftMarker);
CGContextDrawPath(context, kCGPathFill);
const CGAffineTransform rightMarkerTransform=CGAffineTransformMakeRotateTranslate(DEGREES_TO_RADIANS(90),self.frame.size.width,0);
CGPathRef rightMarker=CGPathCreateCopyByTransformingPath(path, &rightMarkerTransform);
CGContextAddPath(context, rightMarker);
CGContextDrawPath(context, kCGPathFill);
const CGAffineTransform leftMarkerBottomTransform=CGAffineTransformMakeRotateTranslate(DEGREES_TO_RADIANS(270),0,self.frame.size.height);
CGPathRef leftMarkerbottom=CGPathCreateCopyByTransformingPath(path, &leftMarkerBottomTransform);
CGContextAddPath(context, leftMarkerbottom);
CGContextDrawPath(context, kCGPathFill);
const CGAffineTransform rightMarkerBottomTransform=CGAffineTransformMakeRotateTranslate(DEGREES_TO_RADIANS(180),self.frame.size.width,self.frame.size.height);
CGPathRef rightMarkerBottom=CGPathCreateCopyByTransformingPath(path, &rightMarkerBottomTransform);
CGContextAddPath(context, rightMarkerBottom);
CGContextDrawPath(context, kCGPathFill); …Run Code Online (Sandbox Code Playgroud) 我创建了一个私有 Pod,但是当我运行时pod install,出现以下错误。
我知道我缺少“源”,但对于私人 Pod,我不想上传到任何 git。存储库。有什么办法可以解决它。
吊舱安装
Analyzing dependencies
Fetching podspec for `MyLib` from `../MyLib`
[!] The `MyLib` pod failed to validate due to 1 error:
- ERROR | attributes: Missing required attribute `source`.
- WARN | homepage: The homepage has not been updated from default
- WARN | summary: The summary is not meaningful.
Run Code Online (Sandbox Code Playgroud)
.podspec如下
Pod::Spec.new do |s|
s.name = "MyLib"
s.version = "0.0.1"
s.summary = "A short description of MyLib."
s.description = "This is a my …Run Code Online (Sandbox Code Playgroud) 我想删除我们在编辑文本字段时看到的UITextInputAssistantItem.我们需要将leadingBarButtonGroups和trailingBarButtonGroups设置为空数组.但导致泄漏和应用程序崩溃,其中广泛使用UITextField.
self.textfield.inputAssistantItem.leadingBarButtonGroups=@[];
self.textfield.inputAssistantItem.trailingBarButtonGroups=@[];
Run Code Online (Sandbox Code Playgroud)
在我当前的viewController中,只有两个textfield和viewdidLoad上面的代码,就是这样.但是,不知道为什么会导致泄漏,当界面有很多textFields时,这对我来说很头疼.
从上面的图像我们可以看到在文本字段生成编辑时生成的泄漏.
如果我将它设置为nil,而不是空数组,我仍然会得到泄漏.
我有以下运行脚本,可在http://oclint-docs.readthedocs.io/en/stable/guide/xcode.html获取
source ~/.bash_profile
cd ${SRCROOT}
xcodebuild clean
xcodebuild | xcpretty -r json-compilation-database --output compile_commands.json
oclint-json-compilation-database -- -report-type xcode
Run Code Online (Sandbox Code Playgroud)
但是,当我执行它时,我收到以下错误。(1 次失败)oclint:未指定足够的位置命令行参数!
oclint 版本是 OCLint 版本 0.13 和 Xcode 9.3.1
我正在使用一个简单的视图来显示文本NumberFormatter我正在使用一个简单的视图来显示特定区域
struct CurrencyView: View {\n let currency:Currency\n var body: some View {\n Text(currency.getFormattedCurrency())\n }\n}\n\nstruct CurrencyView_Previews: PreviewProvider {\n static var previews: some View {\n CurrencyView(currency: Currency(currencyValue: 1.0)).previewLayout(.fixed(width: 300.0, height: 55.0)).environment(\\.locale, .init(identifier: "fr_Fr"))\n }\n}\n\nstruct Currency{\n let currencyValue:Double\n\n func getFormattedCurrency() -> String{\n let formatter = NumberFormatter()\n formatter.numberStyle = .currency\n let formatterCurrency = formatter.string(for: self.currencyValue) ?? ""\n return formatterCurrency\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n我预计预览会显示货币French\xe2\x82\xac 中的货币,正如我在预览中的区域设置中提到的那样。
setMaximumFractionDigits不能使用以下代码.
NSString *input=@"80.90";
NSNumberFormatter *numberFormatter=[[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
[numberFormatter setMaximumFractionDigits:2];
NSNumber *number=[numberFormatter numberFromString:input];
Run Code Online (Sandbox Code Playgroud)
数字转换为80.90000000000001.但我限制了2位小数.那么,我如何得到80.90而不是80.90000000000001
fun multipleParams(id: Int = 1 , name: String) {
...
}
Run Code Online (Sandbox Code Playgroud)
我在课堂上创建了上面的方法.以下方法调用正常工作:
multipleParams(1,"Rose")
Run Code Online (Sandbox Code Playgroud)
是否有可能以某种方式使用它,有时我只通过name,有时两者都通过?
multipleParams(1,"Rose")
multipleParams("Rose")
Run Code Online (Sandbox Code Playgroud) ios ×6
objective-c ×5
xcode ×3
localization ×2
cocoapods ×1
crash ×1
drawrect ×1
fractions ×1
kotlin ×1
memory-leaks ×1
nsarray ×1
nsstring ×1
oclint ×1
parameters ×1
plist ×1
run-script ×1
swiftui ×1
uitextfield ×1
xcode5 ×1
xcode9.3 ×1
xib ×1