Skip to content

Instantly share code, notes, and snippets.

self.quoteText.text = arrayWithSelectedQuotes[randomIndex][selectedCatergory];
// But when you assing to the UI element the object Validates what you set, and if this is -->nil<-- it just puts empty string
if(self.quoteText.text == nil) { // false
NSLog(@"it's nil");
}
if([self.quoteText.text isEqual: @""]) { // true
NSLog(@"It is empty string");
}
#import "QuoteQuiz.h"
@implementation QuoteQuiz
- (id)initWithQuiz:(NSString *)plistName {
if((self = [super init])) {
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:plistName ofType:@"plist"];
self.movieArray = [NSMutableArray arrayWithContentsOfFile:resourcePath];
}
return self;
- (id)initWithQuiz:(NSString*)plistName
{
self = [super init];
if (self)
{
NSString *plistCatPath = [[NSBundle mainBundle] pathForResource:plistName ofType:@"plist"];
self.movieArray = [NSMutableArray arrayWithContentsOfFile:plistCatPath];
}
return self;
}
#import "MyQuiz.h"
#import "QuoteQuizViewController.h"
@interface QuoteQuizViewController ()
@end
@implementation QuoteQuizViewController
#import <Foundation/Foundation.h>
@interface MyQuiz : NSObject
@property (nonatomic, strong) NSMutableArray *quoteArray;
-(id) initWithTheQuiz : (NSString *) plistName;
@end
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/> <!-- Why is that ? -->
</plist>
- (void)nextQuizItem
{
if (self.quizIndex == 999) {
self.quizIndex = 0;
self.statusLabel.text = @"";
} else if ((self.quiz.quizCount-1) > self.quizIndex) {
self.quizIndex++;
} else {
self.quizIndex = 0;
self.statusLabel.text = @"";
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="ljd-vW-cIl">
<rect key="frame" x="20" y="274" width="280" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" title="Button">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleCol
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="ljd-vW-cIl">
<rect key="frame" x="20" y="274" width="280" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" title="Button">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>