久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

是否可以使用字符串和 int 引用變量?

Is it possible to reference a variable with a string and an int?(是否可以使用字符串和 int 引用變量?)
本文介紹了是否可以使用字符串和 int 引用變量?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

是否可以用一個字符串和一個int來引用一個變量,像這樣:

Is it possible to reference a variable with a string and an int, like this:

    int number1;

    int j = 1;

    @"number%i", j = 3; //Hope this makes sense..

上面的代碼給了我警告并且不起作用,怎么可能呢.

The code above gives me warnings and does not work, how could this be done.

我也試過這個,但它不起作用(原因很明顯):

I also tried this, but it doesnt work (for quite obvious reasons):

    int j = 1;

    NSString *refString = [NSString stringWithFormat:@"number%i", j];

    refString = 3;

我真的很掙扎,我知道如何在 Javascript 中做到這一點,但在 Obj-C 中卻不知道,這可能嗎?

Im really struggling with this, I know how to do it in Javascript, but not in Obj-C, is it possible?

推薦答案

這是一個反模式 我稱之為窮人陣列.更好的方法是使用像數組這樣的適當集合,而不是使用一堆秘密相關的變量.如果做得好,帶有數組的代碼通常也會更短更簡潔.

This is an anti-pattern I call the Poor Man's Array. The better way to do this is to use a proper collection like an array instead of a bunch of variables that are secretly related. Done right, the code with an array will usually be a lot shorter and cleaner too.

這篇關于是否可以使用字符串和 int 引用變量?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw stars using Quartz Core?(如何使用 Quartz Core 繪制星星?)
Why does giving addArcWithCenter a startAngle of 0 degrees make it start at 90 degrees?(為什么給 addArcWithCenter 一個 0 度的 startAngle 使它從 90 度開始?)
Find the CGPoint on a UIView rectangle intersected by a straight line at a given angle from the center point(在與中心點成給定角度的直線相交的 UIView 矩形上找到 CGPoint)
How to create a hex color string UIColor initializer in Swift?(如何在 Swift 中創建十六進制顏色字符串 UIColor 初始化程序?)
Are ints always initialized to 0?(整數總是初始化為0嗎?)
How can I use OCMock to verify that a method is never called?(如何使用 OCMock 來驗證某個方法從未被調用?)
主站蜘蛛池模板: 亚洲精品在线免费 | 日韩精品在线播放 | 亚洲视频免费在线 | 97精品超碰一区二区三区 | 久久免费视频在线 | 国产探花在线精品一区二区 | 国产一级视频在线 | 欧美日韩视频在线第一区 | 碰碰视频 | 国产欧美一区二区三区在线播放 | 亚洲一区二区在线播放 | 久久国产精品久久久久久 | 高清一区二区三区 | www日本在线观看 | 国产免费一区二区三区 | 一级网站 | 日日日视频 | h片在线看 | 久久久久久国产免费视网址 | 国产成人精品一区二区三区在线 | 亚洲美女在线一区 | 国产麻豆乱码精品一区二区三区 | 久久免费国产 | 欧美区日韩区 | 嫩草国产 | 久久99精品久久久 | 国产一区二区在线播放视频 | 91久久北条麻妃一区二区三区 | 日韩国产精品一区二区三区 | 日韩国产中文字幕 | 午夜影院网站 | 免费观看一级特黄欧美大片 | 成人在线观看中文字幕 | 久久久久精 | xxxxx黄色片| 玖玖玖在线 | 久久网站黄 | 国产精品久久久久久久久免费软件 | 欧美精品在欧美一区二区 | 中文字幕视频一区二区 | 久久久久9999亚洲精品 |