Here in New York, at least, the eligibility for those units is based on the median income in the neighborhood where the building is. In some cases these affordable units end up with requirements that are pretty substantial, e.g. https://www1.nyc.gov/site/hpd/services-and-information/housi...