[英]Please Help me!! Would anyone can teach me IBAction how to use `isEqualToString` to an `NSArray` object from TableView only on cell?
Anyone can teach me IBAction how to use isEqualToString
to an NSArray
object from a TableView with one cell? 任何人都可以教我IBAction如何在一个单元格的TableView isEqualToString
用作NSArray
对象?
My first page is a TableViewController with 1 Cell and I have created NSSArray object to push the data to second page ViewController. 我的第一页是一个带有1个单元格的TableViewController,我创建了NSSArray对象以将数据推送到第二页ViewController。
I created an IBAction
to play a sound whenever user touch the button in ViewController. 我创建了一个IBAction
来在用户触摸ViewController中的按钮时播放声音。 (It means that When I click on button it loads a sound and according to the data of Cell from NSArray) (这意味着当我单击按钮时,它会加载声音并根据NSArray中的Cell数据进行加载)
"DetailModal" is an NSArray
object from other TableViewController. “ DetailModal”是其他TableViewController的NSArray
对象。
I'm using AudioToolbox and I have created the sound file to soundID 我正在使用AudioToolbox,并且已将声音文件创建为soundID
How can I use isEqualToString
to link the NSArray
object? 如何使用isEqualToString
链接NSArray
对象?
For example: 例如:
I have created a list of soundID like this: 我已经创建了一个soundID列表,如下所示:
NSURL *buttonURL1 = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"A" ofType:@"m4a"]];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)buttonURL1, &soundID1);
NSURL *buttonURL2 = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"I" ofType:@"m4a"]];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)buttonURL2, &soundID2);
and 和
Detail2ViewController.h Detail2ViewController.h
@property (strong, nonatomic) NSArray *DetailModal;
How can I use "isEqualToString" to a NSArray object in IBAction? 如何在IBAction中对NSArray对象使用“ isEqualToString”?
- (IBAction)Sound {
int sound = _DetailModal; (Don't know how to do. Want to equal a object _DetailModal but show error)
if ([_TitleLabel.text isEqualToString:@"/a/"]) { (_TitleLabel is a NSSArray object and equal to _DetailModal from another TableViewController)
AudioServicesPlaySystemSound(soundID1);
}
if ([_TitleLabel.text isEqualToString:@"/i/"]) {
AudioServicesPlaySystemSound(soundID2);
}
}
I have tried but fail... 我已经尝试过但是失败了...
I'm using storyboard 我正在使用情节提要
Thanks for advance! 感谢前进! (I'm really beginner) (我真的是初学者)
What I understand from your question is that you have problem in passing data from one controller to another controller ie from tableviewcontroller to detailview in your case. 我从您的问题中了解到,在您的情况下,您无法将数据从一个控制器传递到另一个控制器,即从tableviewcontroller传递到detailview。
You can use following method in storyboard: 您可以在情节提要中使用以下方法:
Please refer: http://www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2 请参阅: http : //www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2
Modify your condition like that in IBAction
for checking isEqualToString
inside NSArray
:- 像在IBAction
那样修改条件,以检查NSArray
内的isEqualToString
:-
for (NSString *str in _TitleLabel)
{
if([str isEqualToString:@"/a/"])
{
//Write your code
}
if ([str isEqualToString:@"/i/"])
{
//Write your code
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.