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

  • SEARCH
  • Home
  • 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 8922593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:52:42+00:00 2026-06-15T06:52:42+00:00

I am running into a situation where the read and write operations (being done

  • 0

I am running into a situation where the read and write operations (being done by two different threads and two different view controllers) to an XML file are overlapping.

I tried the following logic to use the same NSLock with the two view controllers :

ViewControllerOne:

(on a background thread using dispatch_async)
- (void)writeToXML {
    // get xmlLock (lock declared globally)
    // write
    // unlock
}

ViewControllerTwo:

(on the main thread)
- (void)readFromXML {
    // get xmlLock (lock referenced from ControllerOne)
    // read
    // unlock
}

However, while debugging, I am noticing that even when ControllerOne has locked the xmlLock, ControllerTwo is still able to get it.

What am I missing here ? Also, is there a better approach for doing something like this ?

  • 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-06-15T06:52:50+00:00Added an answer on June 15, 2026 at 6:52 am

    Are you positive it’s the same NSLock instance? Regardless, it seems like a better way might be to have a dispatch queue for that; readFromXML can dispatch_sync onto it, and writeToXML can dispatch_async onto it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running into a situation where I need the atomic sum of two values
I'm running into a situation where a fully qualified route is not being generated
I'm running into a situation where didReceiveMemoryWarning is being called but viewDidUnload is not.
After running into the Yii asset engine I've read the official documentation (http://www.yiiframework.com/wiki/148/understanding-assets/). I
I 'm running into a situation i don't understand and want somebody to enlighten
I am running into a very strange situation with an app I have that
Totally simple situation, but I can't make it work. I am running into an
I'm running into a strange situation with passing a pointer to a structure with
I'm running into this situation where I need to parse a String into an
In MVC2, I am running into a situation where my HttpContext.User.IsInRole(xxx) check immediately after

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.