草庐IT

int_void

全部标签

创建了一个名为nums_list的vector容器,其中存储了一系列的pair<int, int>

vectorpairint,int>>nums_list;for(inti=0;inums.size();i++){nums_list.emplace_back(i,nums[i]);}这段代码创建了一个名为`nums_list`的`vector`容器,其中存储了一系列的`pairint,int>`。代码的逻辑如下:1.创建一个空的`vectorpairint,int>>`容器`nums_list`,用来存储整数对。2.使用`for`循环遍历整数数组`nums`,循环变量`i`从0到`nums`的长度减1。3.在循环中,使用`emplace_back()`函数将一个新的`pairint,int

ios - 隐式转换丢失整数精度 : 'long long' to 'NSInteger' (aka 'int' )

我正在尝试将类型为“longlong”的变量分配给NSUInteger类型,正确的方法是什么?我的代码行:expectedSize=response.expectedContentLength>0?response.expectedContentLength:0;其中expectedSize是NSUInteger类型,response.expectedContentLength的返回类型是'longlong'类型。变量response的类型是NSURLResponse。显示的编译错误是:SemanticIssue:Implicitconversionlosesintegerprecis

objective-c - 使用 void 而不是 IBAction 作为方法的返回类型

我正在学习ObjC和iOS开发。我在我的应用程序中使用的每个组件都是以编程方式创建的(View、按钮、标签等)。这是我的代码...UIButton*btn=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];[self.btnaddTarget:selfaction:@selector(someAction:)forControlEvents:UIControlEventTouchDown];....-(void)someAction{logic}我注意到我可以使用void而不是IBAction作为选择器的返回类型。这是正确的方法吗?会不会

ios - 将 int 转换为 NSString

我以为我已经将int转换为NSString一段时间了,但每次我运行我的代码时,程序都会进入以下行并崩溃。谁能看出我做错了什么?NSString*rssiString=(int)self.selectedBeacon.rssi;UnitySendMessage("Foo","RSSIValue",[rssiStringUTF8String]);这些行应该采用rssi值(这是一个NSInt)将其转换为字符串,然后以它可以读取的格式将其传递给我的统一对象。我做错了什么? 最佳答案 NSString*rssiString=[NSString

ios - ARC 不允许将非 Objective-C 指针类型 void* 隐式转换为 NSString*__strong*

迁移到ARC时出现上述错误。这是代码:staticNSString*cashBalanceKeyPath=@"test";...[xxxforKeyPath:cashBalanceKeyPathoptions:NSKeyValueObservingOptionNewcontext:&cashBalanceKeyPath];...-(void)observeValueForKeyPath:(NSString*)keyPathofObject:(id)objectchange:(NSDictionary*)changecontext:(void*)context{if(&cashBalan

ios - 等待 10 秒后未能返回。主运行循环模式 : kCFRunLoopDefaultMode void SendDelegateMessage(NSInvocation*): delegate

我正在使用CorePlotheader开发一个iOS应用程序。我有不同的横向和纵向用户界面。在方向更改时,我收到此在等待10秒后返回失败。主运行循环模式:kCFRunLoopDefaultModevoidSendDelegateMessage(NSInvocation*):delegate当我尝试修改UIView的框架时。有人可以建议我该怎么做吗。 最佳答案 调试此问题的一些建议,首先尝试弄清楚绘图的哪一部分花费了这么长时间。尝试使用仪器中的TimeProfiler仪器,Hold选项以选择程序陷入困境的图形部分,并检查调用树。尝试有

ios - 示例代码中 AVFoundation.Framework 中的 static void 指针

我正在查看AVFoundation.Framework的示例代码->AVSimpleEditoriOS&我发现了我无法理解的以下行。staticvoid*AVSEPlayerItemStatusContext=&AVSEPlayerItemStatusContext;staticvoid*AVSEPlayerLayerReadyForDisplay=&AVSEPlayerLayerReadyForDisplay;考虑以下staticvoid*AVSEPlayerItemStatusContext=nil;staticvoid*AVSEPlayerLayerReadyForDisplay

ios - FOR 命令中的表达式 (for (int i=0; i < ([arr count]-1);i++){})

我有一个问题,我无法理解NSArray*emptyArr=@[];for(inti=0;i[emptyArrcount]-1是-1但我的应用程序仍然运行NSLog命令!如果我使用一个int变量:NSArray*emptyArr=@[];intcount=[emptyArrcount]-1;for(inti=0;i然后我的应用程序不运行NSLog命令。谁能帮帮我! 最佳答案 这是因为count的返回类型是unsignedint。当您从0中减去1时,您不会得到-1。相反,您下溢到可能的最高unsignedint。它在第二个版本中工作的原

ios - 字符串不能用 int 索引

当我尝试使用最新版本的Swift将label1设置为string的第一个字母时,最后一行出现错误。如何解决这个问题?letpreferences=UserDefaults.standardletname1=""+preferences.string(forKey:"name")!letname2=name1label1.text=name2.substring(from:0) 最佳答案 那是因为substring方法接受String.Index而不是普通的Int。试试这个:letindex=name2.index(str.start

ios - 在 Objective-C 中进行比较 - 使用 ARC 不允许将 'int' 隐式转换为 'id'

我在标有“faultyline”的行收到错误消息“ARC不允许将‘int’隐式转换为‘id’”。我猜这与我正在检查数组中的整数有关,该数组包含对象而不是整数。#import"RandomGenerator.h"@implementationRandomGeneratorNSMutableArray*drawnNumbers;-(int)randomNumber:(int)upperNumber{returnarc4random_uniform(upperNumber);}-(NSMutableArray*)lotteryNumbers:(int)withMaximumDrawnNumb