久久久久久久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 來驗證某個方法從未被調用?)
主站蜘蛛池模板: www.日韩欧美 | 欧美日韩在线一区二区 | 欧美黄页 | 国产精品色 | 这里只有精品999 | 亚洲+变态+欧美+另类+精品 | 免费在线观看成人 | 成人午夜免费福利视频 | 亚洲精品一区中文字幕 | 91麻豆精品国产91久久久久久久久 | 国产午夜av片 | 在线观看视频91 | 三级视频久久 | 91久久国产精品 | 中文字幕综合 | 日本精品在线播放 | 99热精品国产 | 国产精品爱久久久久久久 | 欧美一级免费看 | 亚洲欧美日韩在线 | 久久成人激情 | 日韩午夜电影在线观看 | 日本成人三级电影 | 亚洲视频免费在线观看 | 草草视频在线免费观看 | 日韩欧美不卡 | h视频网站在线观看 | 91视频免费观看 | 国产91精品在线 | 欧美在线播放一区 | 亚洲人成在线播放 | 中文字幕视频在线观看 | 国产激情一区二区三区 | 久草院线| 欧美精品在线看 | 特黄特色大片免费视频观看 | 欧美中文一区 | 中文字幕一区二区三区日韩精品 | 日韩三区在线观看 | 国产精品久久久久久久久久久久午夜片 | 人人人人人爽 |