Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS using nsstring from class in UIViewController
    primarykey
    data
    text
    <p>I've been bashing my head against this for a week solid, I'm sure its been answered before but in all my research i'm just confusing myself more and more.</p> <p>I'm just simply trying to use an NSString from a class (BBDate) in a UILabel in my main UIViewController.</p> <p>BBDate.h</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; @interface BBDate : NSObject { NSString *dateString; } @property (nonatomic, retain) NSString *dateString; @end </code></pre> <p>BBDate.m</p> <pre><code>//just a simple date creation and formatting to try to learn this technique #import "BBDate.h" @implementation BBDate @synthesize dateString; - (void)createDate; { NSDate* date = [NSDate date]; //Create the dateformatter object NSDateFormatter* formatter = [[NSDateFormatter alloc] init]; //Set the required date format [formatter setDateFormat:@"MM-dd-yyyy"]; //Get the string date NSString *string = [formatter stringFromDate:date]; //Display on the console NSLog (@"%@",string); //set variable dateString = string; } @end </code></pre> <p>UIViewController.h</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "BBDate.h" @interface BBFirstViewController : UIViewController { UILabel *dateToday; BBDate *bbDate; } @property (nonatomic, retain) IBOutlet UILabel *dateToday; @property (nonatomic, retain) BBDate *bbDate; @end </code></pre> <p>UIViewController.m</p> <pre><code>#import "BBFirstViewController.h" #import "BBDate.h" @implementation BBFirstViewController @synthesize dateToday, bbDate; ... //for testing i'm just using viewdidload - (void)viewDidLoad { [super viewDidLoad]; dateToday.text = bbDate.dateString; NSLog(@"%@", bbDate.dateString); ... </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload