سؤال

لذلك لدي هذا المتغير في مندوبتي المسماة appdelegate.h:

AVAudioPlayer *introSound;

يلعب بشكل مستمر أثناء الحمل الأول.

[introSound stop];

ما أريد القيام به هو إيقافها من وحدة تحكم منفصلة ، FirstController.m.

حاولت

[AppDelegate.introSound stop];

لكنه ألقى خطأ يقول:

خطأ: متوقع ":" قبل ". رمز

لماذا يحدث هذا؟

هل كانت مفيدة؟

المحلول

أفترض أنك تعني خطأ في المترجم؟ يشير AppDelegate إلى الفصل ، وليس إلى مثيل الفصل الذي هو مندوب التطبيق الخاص بك. للحصول على ذلك من أي مكان ، افعل هذا:

AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate.introSound stop];

تحتاج أيضًا إلى التأكد من أن introsound هو خاصية ، وليس مجرد متغير مثيل لـ AppDelegate.

نصائح أخرى

استخدم بهذه الطريقة التقاط مقاطع فيديو/صوتيات بسيطة وأفضل.

NSMutableURLRequest *request1 = [[[NSMutableURLRequest alloc] init] autorelease];
[request1 setHTTPMethod:@"GET"];
NSError *error;
NSURLResponse *response;

NSString *documentFolderPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSFileManager *fileManager1 = [NSFileManager defaultManager];
NSString *videosFolderPath = [documentFolderPath stringByAppendingPathComponent:@"videos"]; 
//NSString* videosFolderPath = [@"~/Documents/bar.mp3" stringByExpandingTildeInPath];
NSLog(@"video  path:%@",videosFolderPath);
//Check if the videos folder already exists, if not, create it!!!
BOOL isDir;
if (([fileManager1 fileExistsAtPath:videosFolderPath isDirectory:&isDir] && isDir) == FALSE) {
    //[[NSFileManager defaultManager] createDirectoryAtPath:videosFolderPath attributes:nil];
    [fileManager1 createDirectoryAtPath:videosFolderPath withIntermediateDirectories:YES attributes:nil error:nil];
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top