English 中文(简体)
另一种观点认为控制器的吸引力变数
原标题:calling int variable from another view controller

CatsTableViewController.h

@interface CatsTableViewController : UITableViewController {
  NSMutableArray *categoriesArray;
  int catInt;
}
@property int catInt;
@end

我已将其合成在我的<代码>CatsTableViewController.m上,我有<编码>#import “CatsTableViewController.h”,因为我想在()中将这一内容提一下。 CodesTableViewController.m

详细信息:

这条路边正沿着哪一个阵列装到<代码>。 CodesTableViewController.ms 。 如果说明有助于该表确定在<代码>上将使用哪些阵列编号为OfRowsIn Section,以及可在上使用的阵列。

因此,我要问一下,我如何把这一变量从另一个<条码>上说出来?

最佳回答

您也可考虑使用<条码>NSUserDefaults储存<条码>int值。

NSUserDefaults Level Reference 掌握所有信息,以便你开始工作。 除了那里丰富的信息外,这里还有如何拯救和检索<条码>int的简单例子。 (该文本以及关于<代码>float 、>BO

    NS StringNSDateNSDataNSArray):

    -(void)saveToUserDefaults:(int)myInt
    {
        NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
    
        if (standardUserDefaults) {
            [standardUserDefaults setInt:myInt forKey:@"catInt"];
            [standardUserDefaults synchronize];
        }
    }
    
    -(int)retrieveFromUserDefaults
    {
        NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
        int val = 0;
    
        if (standardUserDefaults) 
            val = [standardUserDefaults intForKey:@"catInt"];
    
        return val;
    }
    
问题回答

如果您提到类别<代码>。 CatsTableViewController,例如,名称为catsController 那么,你只能说:

int localCatInt = [catsController catInt]; // your array index




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签