Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 704055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:53:56+00:00 2026-05-14T03:53:56+00:00

This should be a simple question, but I just can’t seem to figure it

  • 0

This should be a simple question, but I just can’t seem to figure it out.

I’m trying to create my own class which will provide a simpler way of playing short sounds using the AudioToolbox framework as provided by Apple. When I import these files into my project and attempt to utilize them, they just don’t seem to work. I was hoping someone would shed some light on what I may be doing wrong here.

simplesound.h

#import <Foundation/Foundation.h>


@interface simplesound : NSObject {

    IBOutlet UILabel *statusLabel;

}

@property(nonatomic, retain) UILabel *statusLabel;

- (void)playSimple:(NSString *)url;

@end

simplesound.m

#import "simplesound.h"


@implementation simplesound

@synthesize statusLabel;

- (void)playSimple:(NSString *)url {

    if (url = @"vibrate") {
        AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
        statusLabel.text = @"VIBRATED!";
    } else {
        NSString *paths = [[NSBundle mainBundle] resourcePath];
        NSString *audioF1ile = [paths stringByAppendingPathComponent:url];
        NSURL *audioURL = [NSURL fileURLWithPath:audioFile isDirectory:NO];
        SystemSoundID mySSID;
        OSStatus error = AudioServicesCreateSystemSoundID ((CFURLRef)audioURL,&mySSID);
        AudioServicesAddSystemSoundCompletion(mySSID,NULL,NULL,simpleSoundDone,NULL);

        if (error) {
            statusLabel.text = [NSString stringWithFormat:@"Error: %d",error];
        } else {
            AudioServicesPlaySystemSound(mySSID);
        }
    }


    static void simpleSoundDone (SystemSoundID mySSID, void *args) {

        AudioServicesDisposeSystemSoundID (mySSID);

    }
}

- (void)dealloc {
    [url release];
}

@end

Does anyone see what I’m trying to accomplish here? Does anyone know how to remedy this code that is supposedly wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:53:56+00:00Added an answer on May 14, 2026 at 3:53 am

    In C based languages, = is an assignment operator, and == is an equality operator.

    So when you write this:

    if (url = @"vibrate") {
    

    That will always return true, since in C (and hence Obj-C), if statements are ‘true’ if what’s in the brackets is not 0, and an = operation returns the assigned value, which in this case is a pointer to the NSString @”vibrate” (which is definitely not zero).

    I don’t know exactly why you’re trying to compare a URL string to @”vibrate”, but the correct way to compare NSString objects is to do something like:

    if ([url isEqualToString:@"vibrate"])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This should be a simple question, but I just can't recall the relevant API.
So this should be a real easy question but I can't seem to find
This should be a simple question, but I haven't been able to find a
This should be very simple question. There are many programming languages out there, compiled
I think, the answer to my question is rather simple, but I just can't
this might sound like a daft question but I can't seem to find a
I know this should be simple and I should know it but it's eluding
This should be a really really simple thing, but for some reason it is
This should be easy for many of you, but for me it's just another
Trying to get started with subsonic but have a simple question about stored procedures

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.