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

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

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

問題描述

是否可以用一個字符串和一個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?

推薦答案

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

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.

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

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

相關(guān)文檔推薦

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 中創(chuàng)建十六進制顏色字符串 UIColor 初始化程序?)
Are ints always initialized to 0?(整數(shù)總是初始化為0嗎?)
How can I use OCMock to verify that a method is never called?(如何使用 OCMock 來驗證某個方法從未被調(diào)用?)
主站蜘蛛池模板: 亚洲视频在线看 | 欧美一级片在线 | 国产天堂在线 | 久久精品在线观看 | 中文字幕免费观看视频 | 精品日韩一区二区三区 | 一区二区福利视频 | 97人人插 | 少妇中文字幕 | 91视频成人 | 色片在线观看 | 中文在线免费观看 | 日产毛片 | 操操操操操操 | 天天操综合 | 男女久久久 | 91久久久久久久久久 | 亚洲国产成人精品女人久久久 | 亚洲欧美视频一区 | 91理论片午午伦夜理片久久 | 黄色影视大全 | 好吊日在线视频 | 日韩在线观看中文字幕 | 国产一区二区日韩 | 日韩欧美在线一区 | 亚洲精品免费在线观看 | v片| 在线a| 真实人妻互换毛片视频 | 欧美日韩国产一区 | 亚洲综合成人网 | 成人爽a毛片一区二区免费 亚洲午夜在线观看 | 国产精品va| 国产精品第一区 | 欧美视频免费 | 99久久视频 | 五月婷婷影院 | 国产欧美在线 | 久久精品2 | 黄色a毛片 | 在线日韩欧美 |