如何转换和比较NSNumber到BOOL?(How to convert and compare NSNumber to BOOL?)
首先,将BOOL值转换为NSNumber,以便将其放入NSUserDefaults。 稍后我想从NSUserDefaults中检索BOOL值,但显然我得到NSNumber而不是BOOL。 我的问题是
- 如何从NSNumber转换回BOOL?
- 如何将NSNumber与BOOL值进行比较。
目前我有:
if (someNSNumberValue == [NSNumber numberWithBool:NO]) { do something }
有什么比较好的方法吗?
谢谢!
First I convert BOOL value to NSNumber in order to put it into NSUserDefaults. Later I would like to retrieve the BOOL value from the NSUserDefaults, but obviously I get NSNumber instead of BOOL. My questions are?
- how to convert back from NSNumber to BOOL?
- How to compare NSNumber to BOOL value.
Currently I have:
if (someNSNumberValue == [NSNumber numberWithBool:NO]) { do something }
any better way to to the comparison?
Thanks!
原文:https://stackoverflow.com/questions/2478984
最满意答案
访问该服务的最简单方法是使用
NodePort
,然后假设您的安全组允许该端口,您可以通过node:nodeport分配的公共ip访问该服务。另外,一种不将您的节点暴露给公共互联网的更好方法是将CloudProvider设置为
AWS
类型并创建服务类型LoadBalancer
,然后该服务将公开配置ELB。Easiest way to access the service is to use a
NodePort
, then assuming your security groups allow that port you can access the service via the public ip of the node:nodeport assigned.Alternately and a better approach to not expose your nodes to the public internet is to setup the CloudProvider to be type
AWS
and create a service typeLoadBalancer
, then the service will be provisioned with an ELB publicly.
相关问答
更多-
您需要将Lambda函数添加到运行EC2服务器的VPC中。这是Lambda VPC支持的公告博客文章,其中包含设置它的步骤。 这是官方文档 。 VPC中的Lambda函数不会获得公共IP地址。 这意味着它将无法访问VPC之外的任何内容。 由于您还需要访问S3,因此您需要设置S3 VPC端点,以便您的功能仍具有S3访问权限。 如果您的功能需要访问VPC之外的其他内容,则必须将其添加到附加了NAT网关的VPC的私有子网中。 You need to add the Lambda function to the V ...
-
访问该服务的最简单方法是使用NodePort ,然后假设您的安全组允许该端口,您可以通过node:nodeport分配的公共ip访问该服务。 另外,一种不将您的节点暴露给公共互联网的更好方法是将CloudProvider设置为AWS类型并创建服务类型LoadBalancer ,然后该服务将公开配置ELB。 Easiest way to access the service is to use a NodePort, then assuming your security groups allow that ...
-
正如我在使用HTTP为RStudio设置Kuberentes集群以及错误页面中的Shiny结果负载平衡一样 ,最可能出现的问题是,当您使用此入口时,您附加的URI不同于直接accesc(/ service1 / vs /),所以你的应用程序丢失,并没有该uri的内容。 使用Nginx Ingress控制器,您可以使用ingress.kubernetes.io/rewrite-target:/ annotation来缓解这一点,并确保即使在入口路径中存在子文件夹时也可以访问/。 因此,您需要使用适当的重写注释 ...
-
无法访问在ubuntu实例AWS上运行的Django服务器(unable to access Django server running on ubuntu instance AWS)[2022-11-01]
验证您的网络访问控制列表应用于子网级别,以查看是否允许相应的流量。 Verify your Network Access Control List applied at a subnet level to see if the appropriate traffic is allowed. -
RStudio服务器在AWS上突然无法访问[关闭](RStudio server suddenly not accessible anymore on AWS [closed])[2021-04-19]
RStudio服务器将其日志保存在/ var / log / syslog中......您是否在那里查看它是否在报告任何内容? RStudio server keeps its logs at /var/log/syslog ... did you look there to see if it is reporting anything? -
无法访问AWS中docker swarm中部署的REST服务(Unable to access REST service deployed in docker swarm in AWS)[2023-06-20]
如部署服务swarm中所述 ,如果您继续阅读,您将找到以下内容: 直接在SWARM NODE上发布服务端口 如果您需要根据应用程序状态做出路由决策,或者需要完全控制将请求路由到服务任务的流程,则使用路由网格可能不是您的应用程序的正确选择。 要直接在运行它的节点上发布服务端口,请使用--publish标志的mode = host选项。 注意:如果使用mode = host直接在swarm节点上发布服务的端口,并且还设置了published =,则会创建一个隐式限制,即您只能在给定的swarm节点上为该服务运行 ... -
我们遇到了同样的问题并通过在单独的服务器上创建代理API端点来解决它,该服务器将接收请求,并将流从AWS S3传输回客户端。 由于此代理端点托管在列入白名单的域中,因此我们不必担心公司的防火墙会阻止请求。 We had this same problem and resolved it by creating a proxy API endpoint on a separate server that would take the request, and pipe the stream from AWS ...
-
由于优先顺序的转变,我们最终没有走那条路。 我们选择的解决方案,就是我们想要的时候,是Hashicorp的Vault来进行中间人API密钥交换。 它足够安全,并且相对容易实现和集成。 它还具有使您的AWS账户能够通过API与其他不受支持的内容进行交互的额外好处。 We ended up not going that route due to priorities shift. The solution we chose, for when we want to do it, was Hashicorp's ...
-
尝试以下listen语句: app.listen(PORT, '0.0.0.0'); 从阅读教程中你提到它看起来像是在监听localhost 。 如果您在本地运行但在容器内部,则这很好, localhost与容器外部的localhost 。 0.0.0.0是未指定的IPv4地址 ,因此Express将绑定在它可以找到的任何IP上,这将是您的请求从容器外部进入的IP。 Try the following listen statement: app.listen(PORT, '0.0.0.0'); From ...
-
将router.Run从router.Run("127.0.0.1:8080")更改为router.Run(":8080")并且它可以正常工作。 正如@elithrar和@ user3591723所建议的那样127.0.0.1(本地主机)只是机器上的环回接口绑定到“:8080”意味着0.0.0.0:8080 - 这意味着所有接口 Changed the router.Run from router.Run("127.0.0.1:8080") to router.Run(":8080") and it wor ...